rspec doesn't see fields dynamically added or removed by cocoon in nested form

微笑、不失礼 提交于 2019-12-06 21:13:35

If you're looking to test JavaScript-related functionality, then you need to pass js: true as an option to the related scenarios:

scenario "nested form", js: true do
  user_sign_in
  contact = FactoryGirl.create(:contact)

  visit new_message_path
  expect(page).to have_text("New message")

  click_link('Add an action')
  expect(page).to have_text("New action")

  user_sign_out
end

In order to do this, you also need either the selenium-webdriver or capybara-webkit gems. My impression is that Selenium is easier to get started with, but the WebKit one runs much faster.

Note that you can also pass js: true to feature, context, or describe if you need to test several scenarios with JavaScript.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!