Every time I want to create an Issue
, I need to link User
with Label
. User has_many Labels and Labels has_many Users.
The problem is that I need to repeat this in a lot of specs every time I create an Issue
.
let(:label) { Fabricate(:label) }
let(:responsible) { Fabricate(:responsible) }
before do
label.stub(:users).and_return([responsible])
responsible.stub(:labels).and_return([label])
end
let(:issue) { Fabricate(:issue, label: label, responsible: responsible)
Should I place this in a helper class? I would like tips to dry it up.
This gem could do the thing: https://github.com/thoughtbot/factory_girl
And after that you could do such things: