Consider using `FactoryGirl.build_stubbed` instead of `FactoryGirl.create` since it's way faster
FactoryGirl provides a build_stubbed
method that stub all the object attributes.
I have the feeling that we could speed up a lot of our unit tests quite easily with a simple change:
user system total real
build_stubbed(:abuse_report) 1.380000 0.130000 1.510000 ( 1.530494)
build(:abuse_report) 6.740000 0.330000 7.070000 ( 7.795627)
create(:abuse_report) 7.010000 0.290000 7.300000 ( 8.117727)
user system total real
build_stubbed(:user) 0.740000 0.100000 0.840000 ( 0.860718)
build(:user) 0.610000 0.030000 0.640000 ( 0.651007)
create(:user) 3.350000 0.180000 3.530000 ( 3.896695)
user system total real
build_stubbed(:project) 1.940000 0.170000 2.110000 ( 2.141562)
build(:project) 8.030000 0.360000 8.390000 ( 9.250054)
create(:project) 13.270000 0.580000 13.850000 ( 15.675928)
Interesting thing to note: using build
is still better than create
(but associations are still persisted!) but build_stubbed
is a deal-breaker here since even associations are stubbed!
Of course, that won't work for feature specs where we need objets in DB, obviously!