[rspec-users] Problem with Custom matcher and Blocks

Brandon Olivares programmer2188 at gmail.com
Thu Apr 2 17:20:18 EDT 2009


> -----Original Message-----
> From: rspec-users-bounces at rubyforge.org [mailto:rspec-users-
> bounces at rubyforge.org] On Behalf Of Matt Wynne
> Sent: Thursday, April 02, 2009 3:55 PM
> To: rspec-users
> Subject: Re: [rspec-users] Problem with Custom matcher and Blocks
> #have_selector is part of webrat. Have you required the appropriate
> files so that method is visible to your new matcher class?

Oops, forgot that.

OK, so I added:

Require 'webrat/core/matchers/have_selector'

On the first line, and directly within the class:

Include Webrat::Matchers

Is this correct?

OK, so now all 16 examples pass. But one of them should be failing -- the
one with the name. Do you see any reason that is still passing?

Again my matches? Method is as follows:

    def matches? response
      response.should have_selector('form#%s' % [@id]) do |form|
        !@block or @block.call form

> As a P.S. I hate to take the wind out of your sails here, but I was
> reflecting only today how, after 9 months of using RSpec to TDD our
> Rails app, we have massaged the view specs down to almost nothing. IMO
> 99% of the time you should be writing a Cucumber feature instead and
> leaving it at that.

Yeah, I'm really confused about that. I thought I've read from some people
that they recommend doing Cucumber, but also view specs, and controller and
model specs to test the different layers. Others say they don't test the
view with specs, so I don't know. I'm doing it for now and see how I feel
about it.


More information about the rspec-users mailing list