[rspec-users] Using Mock / Datamapper / Associations

David Chelimsky dchelimsky at gmail.com
Fri Nov 13 18:38:04 EST 2009

On Fri, Nov 13, 2009 at 10:04 AM, Arco <akleak at gmail.com> wrote:

> I'm using datamapper and have two associated classes:
> - Org - has n, :users
> - User - belongs_to :org
> When I test the User object, I have been able to mock/stub methods of
> the Org object.  Great!
> But - I still need to require 'org.rb' to setup my user tests -
> otherwise Datamapper will complain: "Cannot find the parent_model Org
> for User in org (NameError)"
> Sure I can require the associated object in my test setup, but would
> love to avoid having to do this, as it increases complexity as the
> number of associated classes grows.
> Is there a way to mock the Org object, without having to require it in
> my test setup ??

I don't know much about Datamapper, but if you're referencing an Org object
then it seems reasonable to me that you'd have to require that file. Why
it's not autoloaded I have no idea - have you tried a Datamapper list or IRC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091113/e2f1c46f/attachment.html>

More information about the rspec-users mailing list