On Sat, Dec 26, 2009 at 7:56 PM, David Chelimsky <[email protected]> wrote: > On Sat, Dec 26, 2009 at 6:55 PM, David Chelimsky <[email protected]> > wrote: >> >> On Sat, Dec 26, 2009 at 5:53 PM, Ed Howland <[email protected]> wrote: >>> >>> I hope this isn't a dumb question, but can a custom matcher be written >>> for a possibly non-existant predicate? I know that if the object >>> responds to some predicate? message, RSpec will breate a custom >>> matcher on the fly for it. Such as be_naughty or be_nice for >>> sarah.naughty? and jane.nice? >> >> It's not that RSpec looks at your code and creates predicates for it. When >> you say "jane.should be_nice", RSpec looks to see if jane has a nice?() >> method and uses that if it's there. Subtle, but important difference. > > I should add here, that if you've already defined a be_nice method, it will > be called. RSpec only checks for a predicate when it gets method_missing, > which it wouldn't if you've defined a method already. > HTH, > David
Thanks, David. That helps my understanding a lot. Happy Boxing day, or what's left of it Ed > -- Ed Howland http://greenprogrammer.wordpress.com http://twitter.com/ed_howland _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
