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 ??
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
channel?
Is there a way to mock the Org object, without having to require it in
my test setup ??
Hi Arco
Are you running the spec through something that loads a code loader (eg:
for my specs, spec_helper.rb starts Merb in the test environment), or
just running that one file on its own? That’s the simplest way I can
think this would be failing.