Tag: web testing

Rspec – Rails – 如何遵循redirect

有谁知道如何使rspec遵循redirect(在控制器规范)? (例如,testing/单元具有follow_redirect!) 我试过“follow_redirect!” 和“follow_redirect”,但只能得到 undefined method `follow_redirect!' for #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0xb6df5294> 例如: 当我创build一个帐户,该页面被redirect到帐户页面,我的新帐户应该在列表的顶部。 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! 需要改变成实际工作的东西。