In a Rails app, I'm using RSpec (with Capybara Webkit) to test that a Delete link is working.
In my Rails template I have:
<%= link_to 'Delete', movie_path(@movie),
method: :delete, data: { confirm: 'Are you sure?' } %>
And this is my spec:
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
I get the error:
NoMethodError:
undefined method `accept_modal' for #<Capybara::Webkit::Driver:0x007febc2214908>
It's using the right driver (Webkit) but it doesn't seem to find accept_modal
(which must be called by page.accept_confirm
).
I'm using:
capybara (2.14.0)
capybara-webkit (1.1.0)
rails (5.1.1)
rspec (3.6.0)
rspec-rails (3.6.0)
Note that using the following will work:
click_link 'Delete'
page.driver.browser.accept_js_confirms
But I'd like to understand why accept_confirm
does not.