开发者

Setting up factory_girl with internal array in rails

I have the following shoulda set up which I would like to use factory_girl to have the fake model available in other specs.

So far I have this:

  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 << LeadCaptur开发者_如何学Cer::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

I know how to set up associations in factory_girl but I am not sure how I would set up the above in factory_girl.

Maybe it is not a good fit for this situation.

Can anyone help me out?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜