FactoryGirl screws up rake db:migrate process

后端 未结 4 1460
梦毁少年i
梦毁少年i 2020-12-04 18:00

I am doing TDD/BDD in Ruby on Rails 3 with Rspec (2.11.0) and FactoryGirl (4.0.0). I have a factory for a Category model:

FactoryGirl.define \"Category\" do         


        
4条回答
  •  广开言路
    2020-12-04 18:28

    You shouldn't need to do any of that.. I think the issue is that your argument to FactoryGirl.define..

    try this.

    FactoryGirl.define do
       factory :category do
           name "Foo"
       end
    end
    

    That should work fine, and does not screw up my migrations or load.. Today, I had to fix an issue where I was referencing a model constant from my factory directly and had to put it in a block to fix things.

    FactoryGirl.define do
       factory :category do
           # this causes unknown table isseus
           # state Category::Active
           # this does not.
           state { Category::Active }
       end
    end
    

提交回复
热议问题