【问题标题】:Rails Capybara following render after form submitRails Capybara 在表单提交后渲染
【发布时间】:2015-11-11 13:21:51
【问题描述】:

在我的 Rails 控制器中,我有:

def update
  render @bill if @bill.update(bill_params)
end

在表单上,​​我有一个远程 true,因此使用 ajax 将渲染加载到页面上。

但在我的水豚测试中,我有:

fill_in('bill_period', with: @bill.period)
fill_in('bill_groupname', with: @bill.groupname)
click_button 'update bill'
save_and_open_page

页面现在在渲染中打开,而不是应该在其上渲染的页面。它不会仅通过 capybara 在应用程序本身中执行此操作。 如何防止水豚跟随渲染?

【问题讨论】:

    标签: ruby-on-rails ajax unit-testing testing capybara


    【解决方案1】:

    听起来您正在使用不支持 JavaScript 的默认水豚驱动程序 (rack_test)。您需要切换到 selenium 驱动程序或其他第三方驱动程序才能获得 javascript(以及 ajax)支持 - https://github.com/jnicklas/capybara#selecting-the-driver

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多