We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Hongli Lai (Phusion) (author)
Mon Apr 07 07:33:08 -0700 2008
passenger / test / application_spawner_spec.rb
4f123154 » Hongli Lai (Phusion) 2008-02-27 Reorganize some files. Fini... 1 require 'support/config'
9d714c0d » Hongli Lai (Phusion) 2008-03-01 Rename 'mod_rails' director... 2 require 'passenger/application_spawner'
5ec3dc66 » Hongli Lai (Phusion) 2008-02-27 Refactor tests for Applicat... 3 require 'minimal_spawner_spec'
4 require 'spawn_server_spec'
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 5 require 'spawner_privilege_lowering_spec'
be79ff24 » Hongli Lai (Phusion) 2008-03-02 ApplicationSpawner: catch e... 6 require 'spawner_error_handling_spec'
16201608 » Hongli Lai (Phusion) 2008-03-01 Rename the 'ModRails' names... 7 include Passenger
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 8
9 describe ApplicationSpawner do
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 10 before :all do
11 ENV['RAILS_ENV'] = 'production'
12 @test_app = "stub/railsapp"
13 Dir["#{@test_app}/log/*"].each do |file|
14 File.chmod(0666, file) rescue nil
15 end
16 File.chmod(0777, "#{@test_app}/log") rescue nil
17 end
18
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 19 before :each do
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 20 @spawner = ApplicationSpawner.new(@test_app)
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 21 @spawner.start
22 @server = @spawner
23 end
24
25 after :each do
26 @spawner.stop
27 end
28
5ec3dc66 » Hongli Lai (Phusion) 2008-02-27 Refactor tests for Applicat... 29 it_should_behave_like "a minimal spawner"
30 it_should_behave_like "a spawn server"
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 31
5ec3dc66 » Hongli Lai (Phusion) 2008-02-27 Refactor tests for Applicat... 32 def spawn_application
33 @spawner.spawn_application
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 34 end
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 35 end
be79ff24 » Hongli Lai (Phusion) 2008-03-02 ApplicationSpawner: catch e... 36
37 describe ApplicationSpawner do
d21001ab » Hongli Lai (Phusion) 2008-03-03 Improve error handling in A... 38 it_should_behave_like "handling errors in application initialization"
be79ff24 » Hongli Lai (Phusion) 2008-03-02 ApplicationSpawner: catch e... 39
40 def spawn_application(app_root)
41 @spawner = ApplicationSpawner.new(app_root)
42 begin
43 @spawner.start
44 return @spawner.spawn_application
45 ensure
46 @spawner.stop rescue nil
47 end
48 end
49 end
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 50
51 if Process.euid == ApplicationSpawner::ROOT_UID
52 describe "ApplicationSpawner privilege lowering support" do
53 before :all do
54 @test_app = "stub/railsapp"
55 ENV['RAILS_ENV'] = 'production'
56 end
fd4927d8 » Hongli Lai (Phusion) 2008-02-18 Add specs for some yet-to-b... 57
4f123154 » Hongli Lai (Phusion) 2008-02-27 Reorganize some files. Fini... 58 it_should_behave_like "a spawner that supports lowering of privileges"
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 59
60 def spawn_app(options = {})
17cee789 » Hongli Lai (Phusion) 2008-02-26 - Add test: ApplicationSpaw... 61 options = {
62 :lower_privilege => true,
63 :lowest_user => CONFIG['lowest_user']
64 }.merge(options)
65 @spawner = ApplicationSpawner.new(@test_app,
66 options[:lower_privilege],
67 options[:lowest_user])
975ad9be » Hongli Lai (Phusion) 2008-02-26 Write tests for privilege l... 68 @spawner.start
69 begin
70 app = @spawner.spawn_application
71 yield app
72 ensure
73 app.close
74 @spawner.stop
75 end
76 end
fd4927d8 » Hongli Lai (Phusion) 2008-02-18 Add specs for some yet-to-b... 77 end
edbb8f20 » Hongli Lai (Phusion) 2008-02-18 Add RSpec specifications fo... 78 end