|
17 | 17 | after(:all) { JRuby::Rack.context = nil } |
18 | 18 |
|
19 | 19 | @@rack_env = ENV['RACK_ENV'] |
| 20 | + @@gem_path = Gem.path.dup |
20 | 21 |
|
21 | 22 | after do |
22 | 23 | @@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env |
| 24 | + Gem.path.replace(@@gem_path) |
23 | 25 | end |
24 | 26 |
|
25 | 27 | it "should determine the public html root from the 'public.root' init parameter" do |
|
50 | 52 |
|
51 | 53 | it "should determine the gem path from the gem.path init parameter" do |
52 | 54 | @rack_context.should_receive(:getInitParameter).with("gem.path").and_return "/blah" |
53 | | - @rack_context.should_receive(:getRealPath).with("/blah").and_return "." |
| 55 | + @rack_context.should_receive(:getRealPath).with("/blah").and_return "./blah" |
54 | 56 | booter.boot! |
55 | | - booter.gem_path.should == "." |
| 57 | + booter.gem_path.should == "./blah" |
56 | 58 | end |
57 | 59 |
|
58 | 60 | it "should also be able to determine the gem path from the gem.home init parameter" do |
59 | 61 | @rack_context.should_receive(:getInitParameter).with("gem.home").and_return "/blah" |
60 | | - @rack_context.should_receive(:getRealPath).with("/blah").and_return "." |
| 62 | + @rack_context.should_receive(:getRealPath).with("/blah").and_return "/home/kares/blah" |
61 | 63 | booter.boot! |
62 | | - booter.gem_path.should == "." |
| 64 | + booter.gem_path.should == "/home/kares/blah" |
63 | 65 | end |
64 | 66 |
|
65 | 67 | it "defaults gem path to '/WEB-INF/gems'" do |
66 | | - @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "." |
| 68 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "file:/home/kares/WEB-INF" |
| 69 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF/gems").and_return "file:/home/kares/WEB-INF/gems" |
67 | 70 | booter.boot! |
68 | | - booter.gem_path.should == "./gems" |
| 71 | + booter.gem_path.should == "file:/home/kares/WEB-INF/gems" |
69 | 72 | end |
70 | 73 |
|
71 | 74 | it "gets rack environment from rack.env" do |
|
82 | 85 | booter.rack_env.should == 'production' |
83 | 86 | end |
84 | 87 |
|
85 | | - it "prepends gem_path to ENV['GEM_PATH']" do |
86 | | - ENV['GEM_PATH'] = '/other/gems' |
87 | | - @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/blah" |
| 88 | + it "prepends gem_path to Gem.path" do |
| 89 | + Gem.path.replace [ '/opt/gems' ] |
| 90 | + booter.gem_path = "wsjar:file:/opt/deploy/sample.war!/WEB-INF/gems" |
88 | 91 | booter.boot! |
89 | | - ENV['GEM_PATH'].should == "/blah/gems#{File::PATH_SEPARATOR}/other/gems" |
90 | | - end |
91 | 92 |
|
92 | | - it "keeps ENV['GEM_PATH'] when gem_path is nil" do |
93 | | - ENV['GEM_PATH'] = '/some/other/gems' |
94 | | - booter.layout = layout = double('layout') |
95 | | - layout.stub(:app_path).and_return '.' |
96 | | - layout.stub(:public_path).and_return nil |
97 | | - layout.should_receive(:gem_path).and_return nil |
98 | | - booter.boot! |
99 | | - ENV['GEM_PATH'].should == "/some/other/gems" |
| 93 | + expect( Gem.path ).to eql [ 'wsjar:file:/opt/deploy/sample.war!/WEB-INF/gems', '/opt/gems' ] |
100 | 94 | end |
101 | 95 |
|
102 | | - it "sets ENV['GEM_PATH'] to the value of gem_path if ENV['GEM_PATH'] is not present" do |
103 | | - ENV['GEM_PATH'] = nil |
104 | | - @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/blah" |
| 96 | + it "prepends gem_path to Gem.path if not already present" do |
| 97 | + Gem.path.replace [ "file:/home/gems", "/usr/local/gems" ] |
| 98 | + booter.gem_path = '/usr/local/gems' |
105 | 99 | booter.boot! |
106 | | - ENV['GEM_PATH'].should == "/blah/gems" |
| 100 | + |
| 101 | + expect( Gem.path ).to eql [ "file:/home/gems", "/usr/local/gems" ] |
107 | 102 | end |
108 | 103 |
|
| 104 | +# it "prepends gem_path to ENV['GEM_PATH']" do |
| 105 | +# ENV['GEM_PATH'] = '/opt/gems' |
| 106 | +# @rack_context.should_receive(:getRealPath). |
| 107 | +# with("/WEB-INF").and_return "/opt/deploy/sample.war!/WEB-INF" |
| 108 | +# booter.boot! |
| 109 | +# |
| 110 | +# ENV['GEM_PATH'].should == "/opt/deploy/sample.war!/WEB-INF/gems#{File::PATH_SEPARATOR}/opt/gems" |
| 111 | +# end |
| 112 | + |
| 113 | +# it "prepends gem_path to ENV['GEM_PATH'] if not already present" do |
| 114 | +# ENV['GEM_PATH'] = "/home/gems#{File::PATH_SEPARATOR}/usr/local/gems" |
| 115 | +# booter.gem_path = '/usr/local/gems' |
| 116 | +# booter.boot! |
| 117 | +# |
| 118 | +# ENV['GEM_PATH'].should == "/home/gems#{File::PATH_SEPARATOR}/usr/local/gems" |
| 119 | +# end |
| 120 | + |
| 121 | +# it "keeps ENV['GEM_PATH'] when gem_path is nil" do |
| 122 | +# ENV['GEM_PATH'] = '/usr/local/gems' |
| 123 | +# booter.layout = layout = double('layout') |
| 124 | +# layout.stub(:app_path).and_return '.' |
| 125 | +# layout.stub(:public_path).and_return nil |
| 126 | +# layout.should_receive(:gem_path).and_return nil |
| 127 | +# booter.boot! |
| 128 | +# ENV['GEM_PATH'].should == "/usr/local/gems" |
| 129 | +# end |
| 130 | + |
| 131 | +# it "sets ENV['GEM_PATH'] to the value of gem_path if ENV['GEM_PATH'] is not present" do |
| 132 | +# ENV['GEM_PATH'] = nil |
| 133 | +# @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/blah" |
| 134 | +# booter.boot! |
| 135 | +# ENV['GEM_PATH'].should == "/blah/gems" |
| 136 | +# end |
| 137 | + |
109 | 138 | it "creates a logger that writes messages to the servlet context" do |
110 | 139 | booter.boot! |
111 | 140 | @rack_context.should_receive(:log).with(/hello/) |
|
0 commit comments