kucaahbe / rspec-html-matchers

Old school have_tag, with_tag(and more) matchers for rspec 3 (Nokogiri powered)
http://rubygems.org/gems/rspec-html-matchers
MIT License
199 stars 90 forks source link

Support for AJAX forms #35

Closed ain closed 9 years ago

ain commented 9 years ago

Currently, it is not picking up AJAX forms set with :remote => true, e.g.:

expect(response.body.gsub('\\','')).to have_tag('form', :with => { :action => registration_path, :method => 'post', :remote => true })

Minor thing, but would be nice to have a way for it.

kucaahbe commented 9 years ago

@ain could you provide more details about your environment?

I assume this is about rails app being tested with cucumber+capybara, in that case, actually, gem can't help, because it does nothing with page loading, it works with plain html. If there no content you matching, than it wasn't loaded for reasons depend on you setup.

The second issue, I could assume: :remote => true, passed as parameter to rails forms, becomes data-remote='true' in a <form> tag in resulting html, so if you want to match that, than, you probably need to rewrite matcher like this:

expect(response.body.gsub('\\','')).to have_tag('form', :with => { :action => registration_path, :method => 'post', :'data-remote' => true })
ain commented 9 years ago

I'm using RSpec. Content comes in over UJS as

$('#js_registration__form').html('<header class=\"modal__header\">\n  <h1>Modal headline</h1>\n</header>…');

Your suggestion for :'data-remote' => true works. Thanks. Maybe a simple conversion handle for the matcher?

kucaahbe commented 9 years ago

@ain this gem's policy includes:

Looks like issue was resolved, so I'm closing it, feel free to reopen if have any questions, thanks!

ain commented 9 years ago

Ok @kucaahbe, I can understand the policy. Thanks again for the support.