I''ve been thinking about the wider issues of mocking out the active
record stuff when unit testing. Normally I have a seperate repository
layer with seperate domain objects - there mocking out the repository
(DB-access) is simple. In rails the repository methods are on the
domain objects themsevles, provided by ActiveRecord (still new to this
- so feel free to correct me). What you almost want to be able to do
is to mock out the ActiveRecord methods of your object when testing
it, although that smells to high heaven to me.
There are clear advantages to having a seperate repository layer (it
doesn''t take reading Domain Driven Design to realise this) but I can
understand why rails does it this way - and it is handled nicely
enough. But I can''t help feeling that going down the route of mocking
out parts of a class under unit test smacks a little of yak-shaving.
sam
On 5/3/05, David Corbin <dcorbin-wmGZ+vDKSyrZJqsBc5GL+g@public.gmane.org>
wrote:> Is there any support for unit-testing transactions? That is mocking the
> database out and causing it to fail on a particular
''write''?
>
> David
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
sam
http://www.magpiebrain.com/