hey,
i have a simple associations:
class Account < ActiveRecord::Base
has_many :users
accepts_nested_attributes_for :users
validates_presence_of :users
end
and
class User < ActiveRecord::Base
belongs_to :account
end
i just want to run a simple test:
describe 'a new', Account do
it 'should be valid' do
Factory.build(:account).should be_valid
end
end
with the factories:
Factory.define :account do |a|
a.name { Faker::Company.name }
end
Factory.define :user do |u|
u.association :account
u.email { Faker::Internet.email }
end
but i always run into this error:
'a new Account should be valid' FAILED
Expected #<Account id: nil, name: "Baumbach, Gerlach and Murray" > to be valid, but it was not
Errors: Users has to be present
well, i setup the correct associations, but it doesn't work...
thx for your help.