Skip to content
This repository

Capybara matchers in view specs #302

Closed
wincent opened this Issue · 6 comments

5 participants

Greg Hurrell David Chelimsky Matt Snyder Rully Adrian Santosa Tobias Pfeiffer
Greg Hurrell

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.

Cheers,
Wincent

David Chelimsky
Owner

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.

David Chelimsky
Owner

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

Matt Snyder

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 https://gist.github.com/922147
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?

David Chelimsky dchelimsky closed this issue from a commit
David Chelimsky dchelimsky Update Capybara integration to support 0.4 and 1.0
- this adds capybara matchers to view and helper specs
- Closes #302.
59793dc
Rully Adrian Santosa

It seems the README.md 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.

Tobias Pfeiffer

The documentation "bug" about capybara not working in view specs still exists on the project homepage: https://www.relishapp.com/rspec/rspec-rails 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).

Cheers,
Tobi

David Chelimsky
Owner

@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.