My Model; Household has_many :neighbors and Neighbor belongs_to :household
Each Household must have a neighbor:
validates :neighbors, presence: {message: 'You must enter at least one neighbor']
I am trying to create a factory
factory :household, class: "Household" do
household_name "Brooke"
neighbor
end
factory :neighbor, class: "Neighbor" do
first_name "Tom"
last_name "Brooke"
end
it "has a valid factory" do
household = create(:household, neighbors: :neighbor)
expect(household).to be_valid
end
This gives me:
undefined method `neighbor=' for #<Household:0x007fd45ec85138>
How do I set up Factory Girl to reflect the Association?