水豚按钮 JS 响应 ActionController 错误
Capybara Button JS Response ActionController Error
我正在为我的项目编写一些测试,但遇到了一些问题。在测试中,我只是填写一些字段,我想提交这个表格。它在浏览器中工作,但在测试中,我得到了 formatError
。这是错误:
ActionController::UnknownFormat: CompaniesController#update is missing a template for this request format and variant.
request.formats: ["text/html"]
request.variant: []
小测验:
scenario 'update company with valid params' do
visit company_account_information_path
fill_in 'company_name', with: "Mustername für Firma"
fill_in 'company_owner_name', with: "Mustermann"
click_button "Speichern"
end
我还没有添加一些期望,因为它每次都失败。
编辑:
是的,响应是js!它应该打开一个模式。
要进行 js 测试,您需要在场景中指定 js: true
,并且应该配置像 selenium 或 poltergeist 这样的 webdriver 来使用 capybara 执行 js。
你的测试:
scenario 'update company with valid params', js: true do
visit company_account_information_path
fill_in 'company_name', with: "Mustername für Firma"
fill_in 'company_owner_name', with: "Mustermann"
click_button "Speichern"
end
阅读此文档以配置支持 js 的网络驱动程序 Capybara drivers
我正在为我的项目编写一些测试,但遇到了一些问题。在测试中,我只是填写一些字段,我想提交这个表格。它在浏览器中工作,但在测试中,我得到了 formatError
。这是错误:
ActionController::UnknownFormat: CompaniesController#update is missing a template for this request format and variant.
request.formats: ["text/html"]
request.variant: []
小测验:
scenario 'update company with valid params' do
visit company_account_information_path
fill_in 'company_name', with: "Mustername für Firma"
fill_in 'company_owner_name', with: "Mustermann"
click_button "Speichern"
end
我还没有添加一些期望,因为它每次都失败。
编辑:
是的,响应是js!它应该打开一个模式。
要进行 js 测试,您需要在场景中指定 js: true
,并且应该配置像 selenium 或 poltergeist 这样的 webdriver 来使用 capybara 执行 js。
你的测试:
scenario 'update company with valid params', js: true do
visit company_account_information_path
fill_in 'company_name', with: "Mustername für Firma"
fill_in 'company_owner_name', with: "Mustermann"
click_button "Speichern"
end
阅读此文档以配置支持 js 的网络驱动程序 Capybara drivers