mardi 21 juillet 2015

FactoryGirl - Undefined Method for has-many association

I have a Restaurant model which has_many Cuisines. Following FactoryGirl's docs I have cuisine inside restaurants.rb to link the association:

# restaurants.rb

FactoryGirl.define do
  factory :restaurant do
    cuisine
    name "Test Restaurant"
    ...
  end
end

# cuisines.rb

FactoryGirl.define do
  factory :cuisine do
    name "Test Cuisine"
    ...
  end
end

When I run my tests I get the error:

'method_missing': undefined method 'cuisine=' for #<Restaurant:0x007fdf864f63f8> (NoMethodError)

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire