有谁知道如何使 rspec 遵循重定向(在控制器规范中)?(例如测试/单元有follow_redirect!)
我试过“follow_redirect!” 和“follow_redirect”,但只得到
undefined method `follow_redirect!' for #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0xb6df5294>
例如:
当我创建一个帐户时,页面被重定向到帐户页面,我的新帐户应该位于列表的顶部。
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
但是 FOLLOW_REDIRECT!需要更改为实际有效的东西。