如何告诉RSpec / Capybara期待路由错误?原因是我希望用户点击链接“通过PUT索取牌照”,而不是通过GET /访问路径。
基本上我想要expect ActionController::RoutingError: No route matches [GET] "/plates/claim/1"
。
scenario 'they have to click the claim link' do
create_plates
sign_in_as_doctor
visit claim_plate_path(@plates.first.id)
?????
end
答案 0 :(得分:11)
试试这个
scenario 'they have to click the claim link' do
create_plates
sign_in_as_doctor
expect{visit claim_plate_path(@plates.first.id)}.to raise_error( ActionController::RoutingError)
end