我有这个RSpec:
describe "submitting to the update action" do
before { patch user_path(user) }
specify { expect(response).to redirect_to(signin_path) }
end
这是错误的。我该如何调试?我想看看实际的反应是什么。
答案 0 :(得分:0)
我在跑bundle exec rspec spec/
错误消息不够具体:
rspec ./spec/requests/authentication_pages_spec.rb:65 # Authentication authorization for non-signed-in users in the Users controller submitting to the update action
当我跑bundle exec rspec spec/requests/authentication_pages_spec.rb
我收到了更详细的错误消息:
1) Authentication authorization for non-signed-in users in the Users controller submitting to the update action
Failure/Error: specify { expect(response).to redirect_to(signin_path) }
Expected response to be a redirect to <http://www.example.com/signin> but was a redirect to <http://www.example.com/>.
Expected "http://www.example.com/signin" to be === "http://www.example.com/".
# ./spec/requests/authentication_pages_spec.rb:65:in `block (6 levels) in <top (required)>'
解决方案:expect(response).to redirect_to(root_path)