我正在使用 rspec 和 capybara 为涵盖现有功能的 rails4 应用程序编写集成测试(当我第一次编写应用程序时我很懒惰)。以下提交按钮在浏览器(Chrome)中正常工作并重定向到成功页面(如预期的那样)
<div class="actions">
<%= button_to "RSVP Now", new_event_attendee_path(f), :id => "open-contacts-dialog-btn", :class => "inbox-sf-add-btn tip", :style => "background:lightgreen" %>
</div>
但是,以下测试失败,
describe "should show confirmation message after submitting the form" do
it "should go to success message when form submitted" do
click_link 'See more details'
click_button 'Sign Me Up!'
fill_in 'Email', with: "simon@example.com"
fill_in 'attendee_name', with: "Simon T"
fill_in 'attendee_phone', with: "1234567890"
fill_in 'attendee_num_guests', with: "1"
click_on 'RSVP Now'
page.should have_content("Awesome! You're signed up.")
end
end
出现以下错误:
Failure/Error: click_on 'RSVP Now'
ActionController::RoutingError:
No route matches [POST] "/events/%23%3CActionView::Helpers::FormBuilder:0x007ff9d7e003c0%3E/attendees/new"
我的路线如下所示:https ://gist.github.com/srt32/6076872
我有点迷茫,因为从用户的角度来看,该操作有效,但我无法通过测试来复制该行为。任何帮助,将不胜感激。谢谢!