[rspec-users] Passing self to matchers

David Chelimsky dchelimsky at gmail.com
Mon Apr 13 06:39:18 EDT 2009


On Mon, Apr 13, 2009 at 4:19 AM, Brandon Olivares
<programmer2188 at gmail.com> wrote:
> Hi,
>
> I've noticed in several matchers that the matcher method passes self to the
> constructor of the class. Then that's used to call several of the methods
> used. For instance, in RouteFor, self is passed, and it is used to call
> assert_recognizes.
>
> I'm just curious why this is, and when this is required.

Because assert_recognizes is defined in the context of the example,
not inside the scope of the matcher. This is only necessary in such
cases that helper methods are outside the matcher itself.

HTH,
David

>
> Brandon
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list