Passing self to matchers


#1

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.

Brandon


#2

On Mon, Apr 13, 2009 at 4:19 AM, Brandon O.
removed_email_address@domain.invalid 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