|
|
|
|
|
by urbanautomaton
5051 days ago
|
|
Remember to ensure that your build strategy is set on all associations if you want this to work, e.g. FactoryGirl.define do
factory :user do
association :account, :strategy => :build
end
end
Otherwise when you build a user, the account association will still get persisted to the database.Even if you do this, though, you're still spinning up a whole network of real objects in what is supposed to be a unit test. |
|
If you stick to the above strategy, things are much faster, but more importantly, there are less unintended surprises, like associations doing a create instead of a build, etc.