Commits

Michael Granger committed 5e0474d

Updated for Strelka 0.0.2.

  • Participants
  • Parent commits 533821d

Comments (0)

Files changed (4)

 # .gems generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator
-inversion -v0.10.0
-#strelka -v0.0.1
-loggability -v0.2.3
+inversion -v0.11.2
+strelka -v0.0.2
+loggability -v0.5.0
 

File .tm_properties

+# Settings
+projectDirectory     = "$CWD"
+windowTitle          = "${CWD/^.*\///} «$TM_DISPLAYNAME»"
+excludeInFileChooser = "{$exclude,.hg,pkg}"
+
+TM_RUBY                  = "/Users/mgranger/.rvm/bin/rvm-auto-ruby"
+
+TM_RSPEC_OPTS            = '-rrspec/core/formatters/webkit -Ilib:../Mongrel2/lib'
+TM_RSPEC_FORMATTER       = 'RSpec::Core::Formatters::WebKit'
+
+[ source.ruby ]
+disableIndentCorrections = true
+
 
 	self.developer 'Michael Granger', 'ged@FaerieMUD.org'
 
-	self.dependency 'strelka', '~> 0.0.1.pre'
-	self.dependency 'inversion', '~> 0.9'
+	self.dependency 'strelka', '~> 0.0.2'
+	self.dependency 'inversion', '~> 0.11'
+	self.dependency 'loggability', '~> 0.5'
 	self.dependency 'hoe-deveiate', '~> 0.1', :developer
 
 	self.spec_extras[:licenses] = ["BSD"]
-	self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Strelka Web Application Toolkit']
+	self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Strelka Fancy Error Handler']
 	self.require_ruby_version( '>=1.9.2' )
 	self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
 	self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )

File spec/strelka/app/fancyerrors_spec.rb

 }
 
 require 'rspec'
-require 'mongrel2/testing'
 require 'strelka'
 require 'strelka/app'
-require 'strelka/logging'
+require 'strelka/constants'
+require 'mongrel2/testing'
+require 'loggability/spechelpers'
 require 'strelka/app/fancyerrors'
 require 'strelka/behavior/plugin'
 
 
-class ArrayLogger
-	### Create a new ArrayLogger that will append content to +array+.
-	def initialize( array )
-		@array = array
-	end
-
-	### Write the specified +message+ to the array.
-	def write( message )
-		@array << message
-	end
-
-	### No-op -- this is here just so Logger doesn't complain
-	def close; end
-
-end # class ArrayLogger
-
-
-class FancyErrorTestingApp < Strelka::App
+### Mock with RSpec
+RSpec.configure do |c|
 	include Strelka::Constants
 
-	plugins :routing, :fancyerrors
+	c.mock_with( :rspec )
 
-
-	# Set defaults for all arguments to avoid having to provide them every time
-	def initialize( appid='fancyerrors-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
-		super
-	end
-
-	get 'server' do |req|
-		finish_with HTTP::SERVER_ERROR, "This response intentionally left blank."
-	end
-
-	get 'client' do |req|
-		finish_with HTTP::BAD_REQUEST, "You call that a request?!"
-	end
+	c.include( Loggability::SpecHelpers )
+	c.include( Mongrel2::SpecHelpers )
+	c.include( Strelka::Constants )
 end
 
 
 	TEST_RECV_SPEC = 'tcp://127.0.0.1:9996'
 
 	before( :all ) do
-		Strelka.log.level = Logger::FATAL
-
-		# Only do this when executing from a spec in TextMate
-		if ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
-			Thread.current['logger-output'] = []
-			logdevice = ArrayLogger.new( Thread.current['logger-output'] )
-			Strelka.logger = Logger.new( logdevice )
-			# Strelka.logger.level = level
-			Strelka.logger.formatter = Strelka::Logging::HtmlFormatter.new( Strelka.logger )
-			Mongrel2.logger = Strelka.logger
-		end
-
-		@request_factory = Mongrel2::RequestFactory.new( route: '' )
+		setup_logging()
 	end
 
-	before( :each ) do
-		@app = FancyErrorTestingApp.new
+	let( :request_factory ) { Mongrel2::RequestFactory.new(route: '') }
+
+	let( :appclass ) do
+		Class.new( Strelka::App ) do
+			include Strelka::Constants
+
+			plugins :routing,
+			        :fancyerrors
+
+
+			# Set defaults for all arguments to avoid having to provide them every time
+			def initialize( appid='fancyerrors-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
+				super
+			end
+
+			get 'server' do |req|
+				finish_with HTTP::SERVER_ERROR, "This response intentionally left blank."
+			end
+
+			get 'client' do |req|
+				finish_with HTTP::BAD_REQUEST, "You call that a request?!"
+			end
+		end
+	end
+
+
+	after( :all ) do
+		reset_logging()
 	end
 
 
 
 
 	it "renders server errors using the server error template" do
-		req = @request_factory.get( '/server' )
-		res = @app.handle( req )
+		req = request_factory.get( '/server' )
+		res = appclass.new.handle( req )
 
-		res.body.should =~ /server error template/i
+		res.body.read.should =~ /server error template/i
 	end
 
 	it "renders client errors using the client error template" do
-		req = @request_factory.get( '/client' )
-		res = @app.handle( req )
+		req = request_factory.get( '/client' )
+		res = appclass.new.handle( req )
 
-		res.body.should =~ /client error template/i
+		res.body.read.should =~ /client error template/i
 	end
 
 	it "renders errors using the existing layout template if one is set" do
-		@app.layout = Inversion::Template.new( '<!-- common layout --><?attr body ?>' )
+		app = appclass.new
+		app.layout = Inversion::Template.new( '<!-- common layout --><?attr body ?>' )
 
-		req = @request_factory.get( '/client' )
-		res = @app.handle( req )
+		req = request_factory.get( '/client' )
+		res = app.handle( req )
 
-		res.body.should =~ /common layout/i
+		res.body.read.should =~ /common layout/i
 	end
 
 end