Skip to content

Capybara matchers in view specs #302

wincent opened this Issue Jan 10, 2011 · 6 comments

5 participants

wincent commented Jan 10, 2011

So Capybara 0.4.1.rc just came out with the new Capybara.string method which allows you to use Capybara matchers on arbitrary strings. This is great because it brings us one step closer to being able to transparently use Capybara matchers in view specs (at the moment, we're stuck with using Capybara matchers in acceptance specs and similar-but-slightly-different Webrat matchers in view specs, which is a little uncomfortable).

I understand from this thread that you've already done some work on this, but I can't see any publicly-visible trace of it yet.

So just wanted to get this ticket into the tracker so it doesn't slip off the radar. And if you do have any work in progress, please share it as I'd be glad to help in finishing it off.


RSpec member

The work I had done was with Jonas on Capybara.string :) Where we left things off was I was going to help get matchers into Capybara, but apparently I was too slow to get it in the 0.4.1.rc. I'll touch base w/ Jonas to figure out the best course. Whether in rspec-rails or directly in Capybara, we should have a solution soon.

RSpec member

FYI - slapped together a prototype of a couple of matchers here: I've emailed Jonas (actually the Capybara mailing list - currently awaiting moderation) to discuss where such matchers should live.


We didn't want to introduce Capybara or Webrat into our view specs and using assert_select and css_select was too slow and causing our test suite to take forever to run, so we wrote a custom matcher. Here's the gist
Would like to be able to extend the include_text matcher to support the within chaining and eliminate the contain class to keep things DRYer. Thoughts?

@dchelimsky dchelimsky added a commit that closed this issue Apr 25, 2011
@dchelimsky dchelimsky Update Capybara integration to support 0.4 and 1.0
- this adds capybara matchers to view and helper specs
- Closes #302.

It seems the file has not been updated to reflect this change.
Under the section "Configure:" > "Webrat and Capybara":

Note that Capybara matchers are not available in view or helper specs.

PragTob commented Nov 21, 2011

The documentation "bug" about capybara not working in view specs still exists on the project homepage: and it just got me worried ;-)

Would be nice if someone could fix that (I don't know if and if yes how I could contribute it to the site myself).


RSpec member

@PragTob done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.