水豚 click_button 不会去创建动作
我有一个这样定义的测试:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否涉及 JavaScript?也许尝试使用像 Webkit 这样的驱动程序。
Is there any JavaScript involved? Maybe try using a driver like Webkit.