[rspec-users] before_validation callbacks bypassed when stubbing :valid?
Ashley Moran
ashley.moran at patchspace.co.uk
Wed Apr 16 07:54:44 EDT 2008
On 16 Apr 2008, at 12:34, Edvard Majakari wrote:
> 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.
Or equally, you could have a Factory class that knows how to create
valid objects. This can be handy for generating test data, and
separates it from the class under test. (Some metaprogramming would
let you define that in one class and still have it available as
MyModel.new_valid.)
Zubin - I am still leaning towards the mock approach though, unless
you don't have integration tests for your app, in which case having a
model-layer test suite would add value. (But full-stack integration
tests + model unit tests would be better).
Ashley
--
http://www.patchspace.co.uk/
http://aviewfromafar.net/
More information about the rspec-users
mailing list