[rspec-devel] controller.session not same as session?

Brandon Keepers brandon at collectiveidea.com
Tue Nov 7 23:11:19 EST 2006


The spec:

context "A user logging out" do
   fixtures :users
   controller_name :account

   setup do
     login_as :quentin
     users(:quentin).remember_me
     request.cookies["auth_token"] = cookie_for(:quentin)
   end

   def logout
     get :logout
   end

   specify "should unset :user in session" do
     logout
     controller.session[:user].should_be_nil
   end

   specify "should unset :user in controller.session" do
     logout
     controller.session[:user].should_be_nil
   end
end

The result:

A user logging out
- should unset :user in controller.session
- should unset :user in session (FAILED - 1)
- should be redirected
- should delete remember_me token

1)
Spec::Expectations::ExpectationNotMetError in 'A user logging out  
should unset :user in session'
1 should be nil
./spec/controllers/account_controller_spec.rb:149:in `should  
unset :user in session'

Throwing a breakpoint in and examining the two reveals:

 >> session
=> #<ActionController::TestSession:0x3a8e794 @attributes={:user=>1,  
"flash"=>{}}>
 >> controller.session
=> #<ActionController::TestSession:0x3a797e0 @attributes= 
{:return_to=>nil, "flash"=>{:notice=>"You have been logged out."}}>
 >>

Am I doing something wrong?

Brandon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rspec-devel/attachments/20061107/b8d4b651/attachment.bin 


More information about the rspec-devel mailing list