Mock_model outside of rails

Hello all. I have a quick mock_model question. Is there a way to
use it when doing ActiveRecord testing outside of rails? What I want
to be able to do with my ActiveRecord is this:

class Child
belongs_to :parent
end

child.parent = mock_model(Parent)

Now in rails I can do this, because mock_model does enough to fool
ActiveRecord into think the relationship is valid, but to do this
outside of rails I have to stub! the parent method to return the mock
and only use the stubbed method in it. That’s not particularly safe,
and I bet there’s a simple solution to this problem.

Eric Smith

On Apr 11, 2008, at 10:56 AM, Eric Smith wrote:

Hello all. I have a quick mock_model question. Is there a way to
use it when doing ActiveRecord testing outside of rails?

Right now you can’t because it’s defined in the RailsExampleGroup. Why
don’t you put in a feature request to have it extracted from there so
that it can be used in isolation?

Cheers,
David