[Ruby] Testing Models in Rails

Harry Dean Hudson Jr. dean at ero.com
Fri Jul 27 10:41:19 PDT 2007


On 7/26/07, Aaron Patterson <aaron at tenderlovemaking.com> wrote:

> I trust that the active record callback chain works properly when I call
> save.  I just want to make sure that my callback is in that chain.

Why not just stub your callback with something easily detectable and
check that a) that detectable thing hasn't happened before you call
#save and b) that it has happened after you have called #save? That
seems like it's maybe what you'd really care about from a practical
standpoint and it'd save you from mucking about in ActiveRecord.

Then you can test what is is that your callback actually should be
doing in isolation. I could be missing something, though...?


More information about the Ruby mailing list