Factory_girl factory gem: problem with simple associations


Can anyone familiar with the use of factory_girl please comment on why
I don’t succeed with the following:

has_one_instance = Factory.build(:has_one_class)
assert_equal 10, has_one_instance.belongs_to_class.some_attribute

…when I’ve constructed the relevant factories, as follows:

Factory.define :belongs_to_class do |f|
f.some_attribute 10

f.association :has_one_class, :factory => :has_one_class

Factory.define :has_one_class do |f|


…and the model classes have the indicated belongs_to:has_one

(A further complicating factor may be the peculiar warning message I’m
getting post-factory_girl install: Warning:
Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement)

Thanks for any comment,


No takers, huh?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs