|
18 | 18 |
|
19 | 19 | @@rack_env = ENV['RACK_ENV'] |
20 | 20 | @@gem_path = Gem.path.dup |
| 21 | + @@env_gem_path = ENV['GEM_PATH'] |
21 | 22 |
|
22 | 23 | after do |
23 | 24 | @@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env |
24 | 25 | Gem.path.replace(@@gem_path) |
| 26 | + @@env_gem_path.nil? ? ENV.delete('GEM_PATH') : ENV['GEM_PATH'] = @@env_gem_path |
25 | 27 | end |
26 | 28 |
|
27 | 29 | it "should determine the public html root from the 'public.root' init parameter" do |
|
101 | 103 | expect( Gem.path ).to eql [ "file:/home/gems", "/usr/local/gems" ] |
102 | 104 | end |
103 | 105 |
|
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 |
| 106 | + it "does not change Gem.path if gem_path empty" do |
| 107 | + Gem.path.replace [ '/opt/gems' ] |
| 108 | + booter.gem_path = "" |
| 109 | + booter.boot! |
112 | 110 |
|
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 |
| 111 | + expect( Gem.path ).to eql [ '/opt/gems' ] |
| 112 | + end |
| 113 | + |
| 114 | + it "prepends gem_path to ENV['GEM_PATH'] if jruby.rack.gem_path set to env" do |
| 115 | + @rack_context.should_receive(:getInitParameter).with("jruby.rack.gem_path").and_return "env" |
| 116 | + ENV['GEM_PATH'] = '/opt/gems' |
| 117 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/opt/deploy/sample.war!/WEB-INF" |
| 118 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF/gems").and_return "/opt/deploy/sample.war!/WEB-INF/gems" |
| 119 | + |
| 120 | + booter.boot! |
| 121 | + |
| 122 | + ENV['GEM_PATH'].should == "/opt/deploy/sample.war!/WEB-INF/gems#{File::PATH_SEPARATOR}/opt/gems" |
| 123 | + end |
| 124 | + |
| 125 | + it "does not prepend gem_path to ENV['GEM_PATH'] if jruby.rack.gem_path set not set" do |
| 126 | + ENV['GEM_PATH'] = '/opt/gems' |
| 127 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/opt/deploy/sample.war!/WEB-INF" |
| 128 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF/gems").and_return "/opt/deploy/sample.war!/WEB-INF/gems" |
| 129 | + |
| 130 | + booter.boot! |
| 131 | + |
| 132 | + ENV['GEM_PATH'].should == "/opt/gems" |
| 133 | + end |
| 134 | + |
| 135 | + it "prepends gem_path to ENV['GEM_PATH'] if not already present" do |
| 136 | + @rack_context.should_receive(:getInitParameter).with("jruby.rack.gem_path").and_return "env" |
| 137 | + ENV['GEM_PATH'] = "/home/gems#{File::PATH_SEPARATOR}/usr/local/gems" |
| 138 | + booter.gem_path = '/usr/local/gems' |
| 139 | + booter.boot! |
| 140 | + |
| 141 | + ENV['GEM_PATH'].should == "/home/gems#{File::PATH_SEPARATOR}/usr/local/gems" |
| 142 | + end |
120 | 143 |
|
121 | 144 | # it "keeps ENV['GEM_PATH'] when gem_path is nil" do |
122 | 145 | # ENV['GEM_PATH'] = '/usr/local/gems' |
|
128 | 151 | # ENV['GEM_PATH'].should == "/usr/local/gems" |
129 | 152 | # end |
130 | 153 |
|
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 |
| 154 | + it "sets ENV['GEM_PATH'] to the value of gem_path if ENV['GEM_PATH'] is not present" do |
| 155 | + @rack_context.should_receive(:getInitParameter).with("jruby.rack.gem_path").and_return 'true' |
| 156 | + ENV.delete('GEM_PATH') |
| 157 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/blah" |
| 158 | + @rack_context.should_receive(:getRealPath).with("/WEB-INF/gems").and_return "/blah/gems" |
| 159 | + |
| 160 | + booter.boot! |
| 161 | + |
| 162 | + ENV['GEM_PATH'].should == "/blah/gems" |
| 163 | + end |
137 | 164 |
|
138 | 165 | it "creates a logger that writes messages to the servlet context" do |
139 | 166 | booter.boot! |
|
0 commit comments