|
87 | 87 |
|
88 | 88 | end |
89 | 89 |
|
90 | | -shared_examples "FileSystemLayout" do |
| 90 | +describe JRuby::Rack::FileSystemLayout do |
| 91 | + |
| 92 | + let(:layout) do |
| 93 | + allow(@rack_context).to receive(:getRealPath) { |path| path } |
| 94 | + JRuby::Rack::FileSystemLayout.new(@rack_context) |
| 95 | + end |
91 | 96 |
|
92 | 97 | before do |
93 | 98 | @original_work_dir = Dir.pwd |
|
99 | 104 | Dir.chdir @original_work_dir |
100 | 105 | end |
101 | 106 |
|
| 107 | + it "sets app uri from an app.root context param" do |
| 108 | + FileUtils.mkdir_p 'app/current' |
| 109 | + expect(@rack_context).to receive(:getInitParameter).with("app.root").and_return "#{Dir.pwd}/app/current" |
| 110 | + expect(layout.app_uri).to eq File.expand_path('app/current') |
| 111 | + expect(layout.app_path).to eq "#{Dir.pwd}/app/current" |
| 112 | + end |
| 113 | + |
| 114 | + it "sets app uri from a rails.root context param" do |
| 115 | + base = File.join File.dirname(__FILE__), '../../rails' |
| 116 | + expect(@rack_context).to receive(:getInitParameter).with("rails.root").and_return base |
| 117 | + expect(layout.app_uri).to eq base |
| 118 | + expect(layout.app_path).to eq File.expand_path(base) |
| 119 | + end |
| 120 | + |
102 | 121 | it "sets app and public uri defaults based on a typical (Rails/Rack) app" do |
103 | 122 | FileUtils.mkdir('./public') |
104 | 123 | expect(layout.app_uri).to eq '.' |
|
181 | 200 | end |
182 | 201 |
|
183 | 202 | end |
184 | | - |
185 | | -describe JRuby::Rack::FileSystemLayout do |
186 | | - |
187 | | - let(:layout) do |
188 | | - allow(@rack_context).to receive(:getRealPath) { |path| path } |
189 | | - JRuby::Rack::FileSystemLayout.new(@rack_context) |
190 | | - end |
191 | | - |
192 | | - it_behaves_like "FileSystemLayout" |
193 | | - |
194 | | - it "sets app uri from an app.root context param" do |
195 | | - FileUtils.mkdir_p 'app/current' |
196 | | - expect(@rack_context).to receive(:getInitParameter).with("app.root").and_return "#{Dir.pwd}/app/current" |
197 | | - expect(layout.app_uri).to eq File.expand_path('app/current') |
198 | | - expect(layout.app_path).to eq "#{Dir.pwd}/app/current" |
199 | | - end |
200 | | - |
201 | | - describe "deprecated-constant" do |
202 | | - |
203 | | - it "still works" do |
204 | | - expect(JRuby::Rack::RailsFilesystemLayout).to be JRuby::Rack::FileSystemLayout |
205 | | - end |
206 | | - |
207 | | - end |
208 | | - |
209 | | -end |
210 | | - |
211 | | -describe JRuby::Rack::RailsFileSystemLayout do |
212 | | - |
213 | | - let(:layout) do |
214 | | - allow(@rack_context).to receive(:getRealPath) { |path| path } |
215 | | - JRuby::Rack::RailsFileSystemLayout.new(@rack_context) |
216 | | - end |
217 | | - |
218 | | - it_behaves_like "FileSystemLayout" |
219 | | - |
220 | | - it "sets app uri from a rails.root context param" do |
221 | | - base = File.join File.dirname(__FILE__), '../../rails' |
222 | | - expect(@rack_context).to receive(:getInitParameter).with("rails.root").and_return base |
223 | | - expect(layout.app_uri).to eq base |
224 | | - expect(layout.app_path).to eq File.expand_path(base) |
225 | | - end |
226 | | - |
227 | | -end if defined? JRuby::Rack::RailsFileSystemLayout |
0 commit comments