我如何創建一個燈具ActsAsTaggableOn::tag使用FactoryGirl?如何使用FactoryGirl創建夾具ActsAsTaggableOn?
我想:
/spec/factories/tags.rb
Factory.define ActsAsTaggableOn::Tag do |f|
f.sequence(:name) { |n| "titre#{n}" }
end
/spec/controllers/books_controller.rb
it "should return 2 categories whith books" do
fake_tag = Factory(:tag)
...
end
我得到:
Failure/Error: fake_tag = Factory(:tag)
ArgumentError:
Factory not registered: tag
感謝您的幫助, 文森特
如果您在記錄中驗證了tag_list,則不會 – AndreiMotinga 2016-04-01 17:34:43