On Wed, May 13, 2009 at 11:02 AM, Jarmo Pertman <jarm...@gmail.com> wrote: > On May 12, 6:21 am, David Chelimsky <dchelim...@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)?
I actually think that what you're doing is perfectly fine. Just not the common case. That's why I think it's OK to support explicitly assigning self as subject, but not making that a default behaviour. If it were me, and it's *not*, but if it were, I'd wrap those helpers in an object and make explicit calls. >> 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. > > >> >> HTH, >> David > > Jarmo > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users