[rspec-devel] controller.should_redirect_to in 0.7.0

Brandon Keepers bkeepers at gmail.com
Mon Nov 6 13:20:46 EST 2006


I'm having an issue with controller.should_redirect_to in 0.7.0.   
Here is an example of my spec:

context "A new user signing up" do
   fixtures :users
   controller_name :account
   integrate_views
   setup do
     post :signup, :user => {:email => 'quire at example.com', :password  
=> 'quire',
       :password_confirmation => 'quire' }
   end

   specify "should save a valid " do
     assigns(:user).should_be_valid
     assigns(:user).should_not_be_new_record
   end

   specify "should redirect" do
     controller.should_redirect_to :controller => "/account", :action  
=> "index"
   end
end

Which produces this failure:

Spec::Mocks::MockExpectationError in 'A new user signing up should  
redirect'
controller expected call to redirect_to {:controller=>"/ 
account", :action=>"index"} but it was never received

However, if I insert a breakpoint right before that expectation and  
inspect the response, I can see that the response is a redirect:

 >> response.redirected_to
=> {:controller=>"/account", :action=>"index"}

Any ideas?

Thanks,
Brandon


More information about the rspec-devel mailing list