@@ -35,10 +35,10 @@ class ::CGI::Session::PStore; end
3535 @@rack_env . nil? ? ENV . delete ( 'RACK_ENV' ) : ENV [ 'RACK_ENV' ] = @@rack_env
3636 end
3737
38- it "should default RAILS_ROOT to /WEB-INF" do
39- @rack_context . should_receive ( :getRealPath ) . with ( "/WEB-INF" ) . and_return ". /WEB-INF"
38+ it "should default rails path to /WEB-INF" do
39+ @rack_context . should_receive ( :getRealPath ) . with ( "/WEB-INF" ) . and_return "/usr/apps /WEB-INF"
4040 booter . boot!
41- booter . app_path . should == ". /WEB-INF"
41+ booter . app_path . should == "/usr/apps /WEB-INF"
4242 end
4343
4444 it "leaves ENV['RAILS_ENV'] as is if it was already set" do
@@ -101,98 +101,100 @@ class ::CGI::Session::PStore; end
101101 booter . logger . instance_variable_get ( :@logdev ) . write "hello"
102102 end
103103
104- it "should setup java servlet-based sessions if the session store is the default" ,
105- :lib => [ :stub ] do
104+ describe "Rails 2 environment" , :lib => :stub do
106105
107- booter . boot!
108- booter . should_receive ( :rack_based_sessions? ) . and_return false
106+ before do
107+ booter . stub ( :rails2? ) . and_return true
108+ end
109109
110- booter . session_options [ :database_manager ] = ::CGI ::Session ::PStore
111- booter . setup_sessions
112- booter . session_options [ :database_manager ] . should == ::CGI ::Session ::JavaServletStore
113- end
110+ it "sets up java servlet-based sessions if the session store is the default" do
114111
115- it "should turn off Ruby CGI cookies if the java servlet store is used" ,
116- :lib => [ :stub ] do
112+ booter . boot!
113+ booter . should_receive ( :rack_based_sessions? ) . and_return false
117114
118- booter . boot!
119- booter . should_receive ( :rack_based_sessions? ) . and_return false
115+ booter . session_options [ :database_manager ] = ::CGI ::Session ::PStore
116+ booter . setup_sessions
117+ booter . session_options [ :database_manager ] . should == ::CGI ::Session ::JavaServletStore
118+ end
120119
121- booter . session_options [ :database_manager ] = ::CGI ::Session ::JavaServletStore
122- booter . setup_sessions
123- booter . session_options [ :no_cookies ] . should == true
124- end
120+ it "turns off Ruby CGI cookies if the java servlet store is used" do
125121
126- it "should provide the servlet request in the session options if the java servlet store is used" ,
127- :lib => [ :stub ] do
122+ booter . boot!
123+ booter . should_receive ( :rack_based_sessions? ) . and_return false
128124
129- booter . boot!
130- booter . should_receive ( :rack_based_sessions? ) . twice . and_return false
125+ booter . session_options [ :database_manager ] = ::CGI ::Session ::JavaServletStore
126+ booter . setup_sessions
127+ booter . session_options [ :no_cookies ] . should == true
128+ end
131129
132- booter . session_options [ :database_manager ] = ::CGI ::Session ::JavaServletStore
133- booter . setup_sessions
134- booter . instance_variable_set :@load_environment , true
130+ it "provides the servlet request in the session options if the java servlet store is used" do
135131
136- :: Rack :: Adapter :: Rails . should_receive ( :new ) . and_return app = double ( "rails adapter" )
137- app . should_receive ( :call )
132+ booter . boot!
133+ booter . should_receive ( :rack_based_sessions? ) . twice . and_return false
138134
139- env = { "java.servlet_request" => double ( "servlet request" ) }
140- booter . to_app . call ( env )
141- env [ 'rails.session_options' ] . should have_key ( :java_servlet_request )
142- env [ 'rails.session_options' ] [ :java_servlet_request ] . should == env [ "java.servlet_request" ]
143- end
135+ booter . session_options [ :database_manager ] = ::CGI ::Session ::JavaServletStore
136+ booter . setup_sessions
137+ booter . instance_variable_set :@load_environment , true
144138
145- it "should set the PUBLIC_ROOT constant to the location of the public root" ,
146- :lib => [ :rails23 , :stub ] do
139+ :: Rack :: Adapter :: Rails . should_receive ( :new ) . and_return app = double ( "rails adapter" )
140+ app . should_receive ( :call )
147141
148- begin
149- booter . app_path = File . expand_path ( "../../../rails" , __FILE__ )
150- booter . boot!
151- PUBLIC_ROOT . should == booter . public_path
152- ensure
153- Object . send :remove_const , :PUBLIC_ROOT
142+ env = { "java.servlet_request" => double ( "servlet request" ) }
143+ booter . to_app . call ( env )
144+ env [ 'rails.session_options' ] . should have_key ( :java_servlet_request )
145+ env [ 'rails.session_options' ] [ :java_servlet_request ] . should == env [ "java.servlet_request" ]
154146 end
155- end
156147
157- describe "Rails 2 environment" , :lib => :stub do
148+ it "should set the PUBLIC_ROOT constant to the location of the public root" ,
149+ :lib => [ :rails23 , :stub ] do
158150
159- before :each do
160- $servlet_context = @servlet_context
161- @rack_context . should_receive ( :getContextPath ) . and_return "/foo"
162151 booter . app_path = File . expand_path ( "../../../rails" , __FILE__ )
163152 booter . boot!
164- silence_warnings { booter . load_environment }
153+ expect ( PUBLIC_ROOT ) . to eql booter . public_path
165154 end
166155
167- after ( :each ) { Object . send :remove_const , :PUBLIC_ROOT }
168-
169- after :all do
170- $servlet_context = nil
156+ after ( :each ) do
157+ Object . send :remove_const , :PUBLIC_ROOT if Object . const_defined? :PUBLIC_ROOT
171158 end
172159
173- it "should default the page cache directory to the public root" do
174- ActionController ::Base . page_cache_directory . should == booter . public_path
175- end
160+ context 'booted' do
176161
177- it "should default the session store to the java servlet session store" do
178- ActionController ::Base . session_store . should == CGI ::Session ::JavaServletStore
179- end
162+ before :each do
163+ $servlet_context = @servlet_context
164+ @rack_context . should_receive ( :getContextPath ) . and_return "/foo"
165+ booter . app_path = File . expand_path ( "../../../rails" , __FILE__ )
166+ booter . boot!
167+ silence_warnings { booter . load_environment }
168+ end
180169
181- it "should set the ActionView ASSETS_DIR constant to the public root" do
182- ActionView ::Helpers ::AssetTagHelper ::ASSETS_DIR . should == booter . public_path
183- end
170+ after ( :all ) { $servlet_context = nil }
184171
185- it "should set the ActionView JAVASCRIPTS_DIR constant to the public root/javascripts " do
186- ActionView :: Helpers :: AssetTagHelper :: JAVASCRIPTS_DIR . should == booter . public_path + "/javascripts"
187- end
172+ it "should default the page cache directory to the public root" do
173+ ActionController :: Base . page_cache_directory . should == booter . public_path
174+ end
188175
189- it "should set the ActionView STYLESHEETS_DIR constant to the public root/stylesheets" do
190- ActionView ::Helpers ::AssetTagHelper ::STYLESHEETS_DIR . should == booter . public_path + "/stylesheets"
191- end
176+ it "should default the session store to the java servlet session store" do
177+ ActionController ::Base . session_store . should == CGI ::Session ::JavaServletStore
178+ end
179+
180+ it "should set the ActionView ASSETS_DIR constant to the public root" do
181+ ActionView ::Helpers ::AssetTagHelper ::ASSETS_DIR . should == booter . public_path
182+ end
183+
184+ it "should set the ActionView JAVASCRIPTS_DIR constant to the public root/javascripts" do
185+ ActionView ::Helpers ::AssetTagHelper ::JAVASCRIPTS_DIR . should == booter . public_path + "/javascripts"
186+ end
187+
188+ it "should set the ActionView STYLESHEETS_DIR constant to the public root/stylesheets" do
189+ ActionView ::Helpers ::AssetTagHelper ::STYLESHEETS_DIR . should == booter . public_path + "/stylesheets"
190+ end
191+
192+ it "should set the ActionController.relative_url_root to the servlet context path" do
193+ ActionController ::Base . relative_url_root . should == "/foo"
194+ end
192195
193- it "should set the ActionController.relative_url_root to the servlet context path" do
194- ActionController ::Base . relative_url_root . should == "/foo"
195196 end
197+
196198 end
197199
198200 # NOTE: specs currently only test with a stubbed Rails::Railtie
0 commit comments