水豚 click_button 不会去创建动作

发布于 2024-11-24 21:23:45 字数 754 浏览 0 评论 0原文

我有一个这样定义的测试:

    it "should have allow you to fill out the new form and save a customer" do
        customer = Factory.build(:customer)
        visit new_customer_path
        factory_to_form "customer", customer, ["kf_code", "supported"]
        click_button "customer_submit"
        current_path.should eq(customer_path(Customer.last))
        page.should have_content "created customer"
        page.should have_content customer.long_name
    end

它非常简单,将客户设置为我的客户工厂,然后使用该工厂的数据填写新的操作表单(我的factory_to_form宏的作用),然后单击提交按钮。

我的问题是,提交按钮似乎从未触及创建操作,它会转到“/customers”并且不会保存客户。

该表单是标准的 form_for(@customer) ,按钮只是 f.submit,我想不出这个表单在浏览器中可以正常工作的任何原因但在本次测试中没有。

为什么水豚不会张贴到正确的地方?

I have a test defined like this:

    it "should have allow you to fill out the new form and save a customer" do
        customer = Factory.build(:customer)
        visit new_customer_path
        factory_to_form "customer", customer, ["kf_code", "supported"]
        click_button "customer_submit"
        current_path.should eq(customer_path(Customer.last))
        page.should have_content "created customer"
        page.should have_content customer.long_name
    end

its a pretty simple that that sets customer to my customer factory and then fills in the new actions form with the data from that factory (what my factory_to_form macro does) and the clicks the submit button.

My problem is that the submit button never seems to touch the create action, its going to "/customers" and not saving the customer.

The form is a standard form_for(@customer) and the button is just f.submit, I can't think of any reason why this form would work fine in the browser but not in this test.

Why would capybara not be posting to the right place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2024-12-01 21:23:45

是否涉及 JavaScript?也许尝试使用像 Webkit 这样的驱动程序。

setup do
  Capybara.javascript_driver = :webkit
  Capybara.current_driver = Capybara.javascript_driver
end

Is there any JavaScript involved? Maybe try using a driver like Webkit.

setup do
  Capybara.javascript_driver = :webkit
  Capybara.current_driver = Capybara.javascript_driver
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文