Created
May 10, 2014 00:19
-
-
Save dnszero/ba70116663970a828ce9 to your computer and use it in GitHub Desktop.
Rails, FactoryGirl, and has_and_belongs_to_many
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When testing has_and_belongs_to_many models using rspec and factory girl you should setup your factory the following way: | |
FactoryGirl.define do | |
factory :foo do | |
name "Foo" | |
end | |
factory :bar do | |
name "Bar" | |
foos { |a| [a.association(:foo)] } | |
end | |
end | |
credit: https://coderwall.com/p/o5yssw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment