Sha256: d8017e066f6a5672d260678930aebad0145109788abbffbc67deedd1ebcd666e

Contents?: true

Size: 1.63 KB

Versions: 6

Compression:

Stored size: 1.63 KB

Contents

shared_examples_for "handling errors in application initialization" do
	before :each do
		@stub = setup_rails_stub('foobar')
		@stub.use_vendor_rails('minimal')
	end
	
	after :each do
		teardown_rails_stub
	end

	it "raises an AppInitError if the spawned app raises a standard exception during startup" do
		File.prepend(@stub.environment_rb, "raise 'This is a dummy exception.'\n")
		begin
			spawn_stub_application(@stub)
			violated "Spawning the application should have raised an InitializationError."
		rescue AppInitError => e
			e.child_exception.message.should == "This is a dummy exception."
		end
	end
	
	it "raises an AppInitError if the spawned app raises a custom-defined exception during startup" do
		File.prepend(@stub.environment_rb, %{
			class MyError < StandardError
			end
			
			raise MyError, "This is a custom exception."
		})
		begin
			spawn_stub_application(@stub)
			violated "Spawning the application should have raised an InitializationError."
		rescue AppInitError => e
			e.child_exception.message.should == "This is a custom exception. (MyError)"
		end
	end
	
	it "raises an AppInitError if the spawned app calls exit() during startup" do
		File.prepend(@stub.environment_rb, "exit\n")
		begin
			spawn_stub_application(@stub)
			violated "Spawning the application should have raised an InitializationError."
		rescue AppInitError => e
			e.child_exception.should be_nil
		end
	end
end

shared_examples_for "handling errors in framework initialization" do
	include Utils
	it "raises FrameworkInitError if the framework could not be loaded" do
		lambda { load_nonexistant_framework }.should raise_error(FrameworkInitError)
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
passenger-2.0.1 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.0.2 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.0.3 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.0.4 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.0.5 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.0.6 test/ruby/rails/spawner_error_handling_spec.rb