Skip to content

Commit b1dd3b7

Browse files
committed
[test] refactor rails_booter hacks away
1 parent 92038b1 commit b1dd3b7

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/spec/ruby/jruby/rack/rails_booter_spec.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010

1111
describe JRuby::Rack::RailsBooter do
1212

13-
let(:booter) do
14-
real_logger = org.jruby.rack.logging.BufferLogger.new
15-
JRuby::Rack.logger = JRuby::Rack::Logger.new real_logger
16-
JRuby::Rack::RailsBooter.new JRuby::Rack.context = @rack_context
13+
let(:real_logger) do
14+
org.jruby.rack.logging.BufferLogger.new
1715
end
1816

19-
let(:rails_booter) do
20-
rails_booter = booter; def rails_booter.rails2?; nil end; rails_booter
17+
let(:booter) do
18+
JRuby::Rack.logger = JRuby::Rack::Logger.new(real_logger)
19+
JRuby::Rack.context = @rack_context
20+
JRuby::Rack::RailsBooter.new @rack_context
2121
end
2222

2323
after { JRuby::Rack.context = nil; JRuby::Rack.logger = nil }
2424

2525
it "should determine RAILS_ROOT from the 'rails.root' init parameter" do
2626
@rack_context.should_receive(:getInitParameter).with("rails.root").and_return "/WEB-INF"
2727
@rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "./WEB-INF"
28-
rails_booter.boot!
29-
rails_booter.app_path.should == "./WEB-INF"
28+
booter.boot!
29+
booter.app_path.should == "./WEB-INF"
3030
end
3131

3232
before do
@@ -41,62 +41,62 @@
4141

4242
it "should default rails path to /WEB-INF" do
4343
@rack_context.should_receive(:getRealPath).with("/WEB-INF").and_return "/usr/apps/WEB-INF"
44-
rails_booter.boot!
45-
rails_booter.app_path.should == "/usr/apps/WEB-INF"
44+
booter.boot!
45+
booter.app_path.should == "/usr/apps/WEB-INF"
4646
end
4747

4848
it "leaves ENV['RAILS_ENV'] as is if it was already set" do
4949
ENV['RAILS_ENV'] = 'staging'
50-
rails_booter.boot!
50+
booter.boot!
5151
ENV['RAILS_ENV'].should == 'staging'
52-
rails_booter.rails_env.should == "staging"
52+
booter.rails_env.should == "staging"
5353
end
5454

5555
it "determines RAILS_ENV from the 'rails.env' init parameter" do
5656
ENV['RAILS_ENV'] = nil
5757
@rack_context.should_receive(:getInitParameter).with("rails.env").and_return "test"
58-
rails_booter.boot!
59-
rails_booter.rails_env.should == "test"
58+
booter.boot!
59+
booter.rails_env.should == "test"
6060
end
6161

6262
it "gets rails environment from rack environmnent" do
6363
ENV.delete('RAILS_ENV')
6464
ENV['RACK_ENV'] = 'development'
6565
@rack_context.stub(:getInitParameter)
66-
rails_booter.boot!
67-
rails_booter.rails_env.should == 'development'
66+
booter.boot!
67+
booter.rails_env.should == 'development'
6868
end
6969

7070
it "default RAILS_ENV to 'production'" do
7171
ENV.delete('RAILS_ENV'); ENV.delete('RACK_ENV')
72-
rails_booter.boot!
73-
rails_booter.rails_env.should == "production"
72+
booter.boot!
73+
booter.rails_env.should == "production"
7474
end
7575

7676
it "should set RAILS_RELATIVE_URL_ROOT based on the servlet context path" do
7777
@rack_context.should_receive(:getContextPath).and_return '/myapp'
78-
rails_booter.boot!
78+
booter.boot!
7979
ENV['RAILS_RELATIVE_URL_ROOT'].should == '/myapp'
8080
end
8181

8282
it "should append to RAILS_RELATIVE_URL_ROOT if 'rails.relative_url_append' is set" do
8383
@rack_context.should_receive(:getContextPath).and_return '/myapp'
8484
@rack_context.should_receive(:getInitParameter).with("rails.relative_url_append").and_return "/blah"
85-
rails_booter.boot!
85+
booter.boot!
8686
ENV['RAILS_RELATIVE_URL_ROOT'].should == '/myapp/blah'
8787
end
8888

8989
it "should determine the public html root from the 'public.root' init parameter" do
9090
@rack_context.should_receive(:getInitParameter).with("public.root").and_return "/blah"
9191
@rack_context.should_receive(:getRealPath).with("/blah").and_return "."
92-
rails_booter.boot!
93-
rails_booter.public_path.should == "."
92+
booter.boot!
93+
booter.public_path.should == "."
9494
end
9595

9696
it "should default public root to '/'" do
9797
@rack_context.should_receive(:getRealPath).with("/").and_return "."
98-
rails_booter.boot!
99-
rails_booter.public_path.should == "."
98+
booter.boot!
99+
booter.public_path.should == "."
100100
end
101101

102102
RAILS_ROOT_DIR = File.expand_path("../../../rails", __FILE__)

0 commit comments

Comments
 (0)