I've got a factory that creates a record that has 2 has_many
associations, but I keep returning a nil object in one of my
associations. This is my first project using factory_girl and I just
wondered if I had my factory set-up correctly.
Factory.define :project_with_solutions, :class => Project do |f|
f.name 'Project with solutions'
f.benefits {|benefits| [benefits.association(:benefit)]}
f.solutions {|solutions| [solutions.association(:solution)]}
end
# Here's my test
@project = Factory.create(:project_with_solutions)
@benefit = @project.benefits.find(:first)
get :edit, :project_id => @project, :id => @
benefit.id
assert_response :success
As you can see, I need to get an instance of a benefit as well as a
project. I'm getting a whiny nil error on my test, but I was under the
impression that the way my factory is setup, it would return saved
instances of a benefit record.
Any help on this is greatly appreciated.
Matthew