我不知道我在做什麼錯,但每次我嘗試測試重定向時,我得到這個錯誤:「@request必須是一個ActionDispatch ::請求「如何測試重定向與Rspec和水豚
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)>'
我在水豚(1.1.2)和Rails 3.2中使用RSpec-rails(2.9.0)。如果有人能夠解釋爲什麼會發生這種情況,我將不勝感激。爲什麼我不能以這種方式使用期望?
也許我錯過了一些東西,但是'assert_redirected_to'有什麼問題? –
@約瑟夫魏斯曼,我得到了同樣的錯誤! – Mohamad