我有以下设置,我想使用factory_girl在其他规格中提供假模型。
到目前为止,我有这个:
context "on POST to parse" do
setup do
@fuzzy_lead = LeadCapturer::FuzzyLead.new
parts = LeadCapturer::LeadPartArray.new
parts << LeadCapturer::LeadPart.new('Mc Burney & Cowan', LeadCapturer::TextTag.new, 0)
parts << LeadCapturer::LeadPart.new('2 Lena Street', LeadCapturer::TextTag.new, 1)
parts << LeadCapturer::LeadPart.new('Belfast', LeadCapturer::TextTag.new, 2)
parts << LeadCapturer::LeadPart.new('Down', LeadCapturer::TextTag.new, 3)
parts << LeadCapturer::LeadPart.new('BT5 5BJ', LeadCapturer::PostCodeTag.new, 4)
parts << LeadCapturer::LeadPart.new('Tel: 028 9047 1054', LeadCapturer::PhoneTag.new, 5)
parts << LeadCapturer::LeadPart.new('Fax: 028 9047 1054', LeadCapturer::FaxTag.new, 6)
parts << LeadCapturer::LeadPart.new('infa@mcburneyandcowan.com', LeadCapturer::EmailTag.new, 7)
parts << LeadCapturer::LeadPart.new('http://www.mcburneyandcowan.com/', LeadCapturer::WebSiteTag.new, 8)
parts << LeadCapturer::LeadPart.new('General Manager: Mike Halliday', LeadCapturer::ContactTag.new, 9)
@fuzzy_lead.instance_eval do
@parts = parts
end
end
我知道如何在factory_girl中设置关联,但我不确定如何在factory_girl中设置上述内容。
也许这不适合这种情况。
任何人都可以帮助我吗?