【发布时间】:2017-11-08 03:46:27
【问题描述】:
在 Rails 应用程序中,我使用 RSpec(与 Capybara Webkit)来测试删除链接是否正常工作。
在我的 Rails 模板中,我有:
<%= link_to 'Delete', movie_path(@movie),
method: :delete, data: { confirm: 'Are you sure?' } %>
这是我的规格:
require 'rails_helper'
describe "Deleting a movie", js: true do
it "destroys the movie and shows the movie listing without the deleted movie" do
movie = Movie.create(movie_attributes)
visit movie_path(movie)
page.accept_confirm do
click_link 'Delete'
end
expect(current_path).to eq(movies_path)
expect(page).not_to have_text(movie.title)
end
end
我得到错误:
NoMethodError:
undefined method `accept_modal' for #<Capybara::Webkit::Driver:0x007febc2214908>
它使用了正确的驱动程序 (Webkit),但似乎找不到 accept_modal(必须由 page.accept_confirm 调用)。
我正在使用:
capybara (2.14.0)
capybara-webkit (1.1.0)
rails (5.1.1)
rspec (3.6.0)
rspec-rails (3.6.0)
请注意,使用 以下方法会起作用:
click_link 'Delete'
page.driver.browser.accept_js_confirms
但我想了解为什么accept_confirm 没有。
【问题讨论】:
标签: ruby-on-rails rspec capybara rspec-rails capybara-webkit