我不知道自己做错了什么,但每次我尝试测试重定向时,都会出现这个错误:“@request必须是ActionDispatch :: Request”
context "as non-signed in user" do
it "should redirect to the login page" do
expect { visit admin_account_url(account, host: get_host(account)) }.to redirect_to(signin_path)
end
end
1) AdminAccountPages Admin::Accounts#show as non-signed in user should redirect to the login page
Failure/Error: expect { visit admin_account_url(account, host: get_host(account)) }.to redirect_to(signin_path)
ArgumentError:
@request must be an ActionDispatch::Request
# ./spec/requests/admin_account_pages_spec.rb:16:in `block (4 levels) in <top (required)>'
我正在使用RSpec-rails(2.9.0)和Capybara(1.1.2)与Rails 3.2。如果有人能解释一下为什么会发生这种情况,为什么我不能以这种方式使用expect,我将不胜感激。
assert_redirected_to
有什么问题吗? - Joseph Weissman