[rspec-users] [RSpec] implicit receiver for should problem when helper predicate methods are in use

David Chelimsky dchelimsky at gmail.com
Wed May 13 12:08:33 EDT 2009


On Wed, May 13, 2009 at 11:02 AM, Jarmo Pertman <Jarmo.P at gmail.com> wrote:
> On May 12, 6:21 am, David Chelimsky <dchelim... at gmail.com> wrote:
>>
>> I don't want to promote using self as subject. I think being able to
>> do so explicitly, as we can now with your previous patch, is perfectly
>> reasonable. But doing so is a bit of a trick in my view, and runs
>> counter to the overall intent of the structure of examples of
>> behaviour of an object or sub-system. "should" is about that object or
>> sub-system, not self.
> I'm also thinking that maybe I'm doing something wrong when using this
> approach, but cannot think of any better way. Do you have any
> suggestions how to get rid of using self as a subject in my context?
> Maybe i'm not aware of some best practices when it comes to using
> helper methods. Should I monkey-patch Watir (or some other library) to
> add methods to it like has_text? and so on in which case subject would
> be $browser (which is actually correct)?
>
>
>>
>> If your whole suite is using this, you can localize the "subject
>> {self}" call, however, in spec_helper, like this:
>>
>> class Spec::ExampleGroup
>>   subject {self}
>> end
> Thank you for this great tip! I think that this solution will satisfy
> me.

Great!

Cheers,
David

>
>
>>
>> HTH,
>> David
>
> Jarmo
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list