1414java_import org . jruby . rack . rails . RailsRackApplicationFactory
1515
1616describe "integration" do
17-
17+
1818 #after(:all) { JRuby::Rack.context = nil }
19-
19+
2020 describe 'rack (lambda)' do
2121
2222 before do
9696 set_compat_version servlet_context
9797 servlet_context
9898 end
99-
99+
100100 it "initializes (pooling by default)" do
101101 listener = org . jruby . rack . rails . RailsServletContextListener . new
102102 listener . contextInitialized javax . servlet . ServletContextEvent . new ( servlet_context )
103-
103+
104104 rack_factory = servlet_context . getAttribute ( "rack.factory" )
105105 rack_factory . should be_a ( RackApplicationFactory )
106106 rack_factory . should be_a ( PoolingRackApplicationFactory )
128128 end
129129
130130 end
131-
131+
132132 describe 'rails 3.0' , :lib => :rails30 do
133133
134134 before ( :all ) { copy_gemfile ( "rails30" ) }
135135
136- let ( : base_path) { "file://#{ STUB_DIR } /rails30" }
136+ def base_path ; "file://#{ STUB_DIR } /rails30" end
137137
138138 it_should_behave_like 'a rails app'
139139
153153 @runtime = @rack_factory . getApplication . getRuntime
154154 expect_to_have_monkey_patched_chunked
155155 end
156-
156+
157157 end
158158
159159 context "initialized (custom)" do
178178
179179 before ( :all ) { copy_gemfile ( "rails31" ) }
180180
181- let ( : base_path) { "file://#{ STUB_DIR } /rails31" }
181+ def base_path ; "file://#{ STUB_DIR } /rails31" end
182182
183183 it_should_behave_like 'a rails app'
184184
213213 @runtime = @rack_factory . getApplication . getRuntime
214214 expect_to_have_monkey_patched_chunked
215215 end
216-
216+
217217 end
218218
219219 end
222222
223223 before ( :all ) { copy_gemfile ( "rails32" ) }
224224
225- let ( : base_path) { "file://#{ STUB_DIR } /rails32" }
225+ def base_path ; "file://#{ STUB_DIR } /rails32" end
226226
227227 it_should_behave_like 'a rails app'
228228
249249
250250 should_eval_as_eql_to "Rails.logger.level" , Logger ::INFO
251251 end
252-
252+
253253 it "sets up public_path (as for a war)" do
254254 @runtime = @rack_factory . getApplication . getRuntime
255255 should_eval_as_eql_to "Rails.public_path" , "#{ STUB_DIR } /rails32"
256256 # make sure it was set early on (before initializers run) :
257257 should_eval_as_not_nil "defined? Rails32::Application::PUBLIC_PATH"
258258 should_eval_as_eql_to "Rails32::Application::PUBLIC_PATH" , "#{ STUB_DIR } /rails32"
259259 # check if image_tag resolves path to images correctly :
260- should_eval_as_eql_to %q{
260+ should_eval_as_eql_to %q{
261261 config = ActionController::Base.config;
262262 asset_paths = ActionView::Helpers::AssetTagHelper::AssetPaths.new(config);
263263 image_path = asset_paths.compute_public_path('image.jpg', 'images');
264264 image_path[0, 18]
265265 } , '/images/image.jpg?'
266266 end
267-
267+
268268 it "disables rack's chunked support (by default)" do
269269 @runtime = @rack_factory . getApplication . getRuntime
270270 expect_to_have_monkey_patched_chunked
271271 end
272-
272+
273273 end
274-
274+
275275 end
276276
277277 describe 'rails 4.0' , :lib => :rails40 do
278278
279279 before ( :all ) { copy_gemfile ( "rails40" ) }
280280
281- let ( : base_path) { "file://#{ STUB_DIR } /rails40" }
281+ def base_path ; "file://#{ STUB_DIR } /rails40" end
282282
283283 it_should_behave_like 'a rails app'
284284
300300 should_eval_as_not_nil "Rails.logger"
301301 # NOTE: TaggedLogging is a module that extends the instance now :
302302 should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::TaggedLogging" , true
303- should_eval_as_eql_to "Rails.logger.instance_variable_get(:'@logdev').dev.class.name" ,
303+ should_eval_as_eql_to "Rails.logger.instance_variable_get(:'@logdev').dev.class.name" ,
304304 'JRuby::Rack::ServletLog'
305305 should_eval_as_eql_to "Rails.logger.level" , Logger ::INFO
306306 end
307-
307+
308308 it "sets up public_path (as for a war)" do
309309 @runtime = @rack_factory . getApplication . getRuntime
310310 should_eval_as_eql_to "Rails.public_path.to_s" , "#{ STUB_DIR } /rails40"
311- should_eval_as_eql_to %q{
312- config = ActionController::Base.config ;
313- asset_paths = ActionView::Helpers::AssetTagHelper::AssetPaths .new(config) ;
314- image_path = asset_paths.compute_public_path ('image.jpg', 'images ');
315- image_path[0, 18 ]
316- } , '/images/image.jpg? '
311+ should_eval_as_eql_to %q{
312+ class AssetPathTest; include ActionView::Helpers::AssetUrlHelper end ;
313+ asset_helper = AssetPathTest .new;
314+ image_path = asset_helper.image_path ('image.jpg');
315+ image_path[0, 17 ]
316+ } , '/images/image.jpg'
317317 end
318-
318+
319319 end
320-
320+
321321 end
322-
322+
323323 describe 'rails 2.3' , :lib => :rails23 do
324324
325325 before ( :all ) do
343343 should_eval_as_not_nil "defined?(Rack.release)"
344344 should_eval_as_eql_to "Rack.release.to_s[0, 3]" , '1.1'
345345 end
346-
346+
347347 it "booted with a servlet logger" do
348348 @runtime = @rack_factory . getApplication . getRuntime
349349 should_eval_as_not_nil "defined?(Rails)"
350350 should_eval_as_not_nil "defined?(Rails.logger)"
351-
351+
352352 should_eval_as_not_nil "defined?(ActiveSupport::BufferedLogger) && Rails.logger.is_a?(ActiveSupport::BufferedLogger)"
353353 should_eval_as_not_nil "Rails.logger.send(:instance_variable_get, '@log')"
354- should_eval_as_eql_to "log = Rails.logger.send(:instance_variable_get, '@log');" +
354+ should_eval_as_eql_to "log = Rails.logger.send(:instance_variable_get, '@log');" +
355355 "log.class.name" , 'JRuby::Rack::ServletLog'
356356 should_eval_as_eql_to "Rails.logger.level" , Logger ::INFO
357-
357+
358358 @runtime . evalScriptlet "Rails.logger.debug 'logging works'"
359359 end
360-
360+
361361 end
362362
363363 end
364-
364+
365365 def expect_to_have_monkey_patched_chunked
366366 @runtime . evalScriptlet "require 'rack/chunked'"
367367 script = %{
368368 headers = { 'Transfer-Encoding' => 'chunked' }
369369
370- body = [ \" 1\" .freeze, \" \" , \" \n second\" ]
370+ body = [ \" 1\" .freeze, \" \" , \" \n second\" ]
371371
372372 if defined? Rack::Chunked::Body # Rails 3.x
373373 body = Rack::Chunked::Body.new body
@@ -382,7 +382,7 @@ def expect_to_have_monkey_patched_chunked
382382 }
383383 should_eval_as_eql_to script , "1\n second"
384384 end
385-
385+
386386 def initialize_rails ( env = nil , servlet_context = @servlet_context )
387387 if ! servlet_context || servlet_context . is_a? ( String )
388388 base = servlet_context . is_a? ( String ) ? servlet_context : nil
@@ -407,7 +407,7 @@ def new_servlet_context(base_path = nil)
407407 set_compat_version servlet_context
408408 servlet_context
409409 end
410-
410+
411411 def set_compat_version ( servlet_context = @servlet_context )
412412 if JRuby . runtime . is1_9
413413 servlet_context . addInitParameter ( "jruby.compat.version" , '1.9' )
0 commit comments