On Wed, Apr 16, 2008 at 1:05 AM, Zubin Henner <[EMAIL PROTECTED]> wrote:
> I'm testing an ActiveRecord model using rspec and mocha, and found that
>  if I stub out the :valid? method, all before_validation callbacks are
>  also skipped!

Naturally, as it is AR's valid method which triggers those callbacks,
and you just stubbed it.

Not a straight answer to your question, but hopefully helpful
nevertheless: you could consider implementing
class method new_valid for each of your objects, so that whenever the
concept of a valid object changes, there's
only one place you have to fix. However, as Ashley suggested, it might
be that you'd rather want to resort to pure
mock objects instead.

-- 
"One day, when he was naughty, Mr Bunnsy looked over the hedge into
Farmer Fred's field and it was full of fresh green lettuces. Mr
Bunnsy, however, was not full of lettuces. This did not seem fair."
 -- Terry Pratchett, Mr. Bunnsy Has An Adventure
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to