Does anyone know how to make rspec follow a redirect (in a controller spec)? (e.g test/unit has follow_redirect!)
I have tried "follow_redirect!" and "follow_redirect" but only get
undefined method `follow_redirect!' for #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0xb6df5294>   For example:
 When I create an account the page is redirected to accounts page and my new account should be at the top of the list.
it "should create an account" do   post :create, :name => "My New Account"   FOLLOW_REDIRECT!   response.code.should == "200"   accounts = assigns[:accounts]   accounts[0].name.should == "My New Account" end   But FOLLOW_REDIRECT! needs to be changed to something that actually works.
I think this is the default behavior for rspec-rails controller tests, in the sense that you can set an expectation on the response status and/or path, and test for success.
For example:
it "should create an account" do   post :create   response.code.should == "302"   response.should redirect_to(accounts_path) end 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With