Sha256: e0cd1cc03ab318853b169fef4408912022cba7f745d7ffd2f1b4ff63c926f66d

Contents?: true

Size: 1.66 KB

Versions: 4

Compression:

Stored size: 1.66 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).close
			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).close
			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).close
			violated "Spawning the application should have raised an InitializationError."
		rescue AppInitError => e
			e.child_exception.class.should == SystemExit
		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.close }.should raise_error(FrameworkInitError)
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
passenger-2.2.0 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.2.1 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.1.3 test/ruby/rails/spawner_error_handling_spec.rb
passenger-2.2.2 test/ruby/rails/spawner_error_handling_spec.rb