Capybara matcher for AJAX data-remote="true"

I’m trying to test if my page has an AJAX link, so I believe in rails, that would mean the link should contain the html of .

I’m trying to test that using Capybara/RSpec with the following line:

expect(page).to have_css “a”, “data-remote” => true

and oddly enough, that passes the test, because I think the have_css method just ignores “data-remote” if it doesn’t understand it, can anyone confirm if that’s the case and also how to properly test for data-remote?


I did not test it, but probably you should use something like this:

expect(page).to have_css 'a[data-remote="true"]'

In your example you are passing data-remote: true as option for have_css method, but it is most probably ignored.