ArgumentError: Factory not registered

后端 未结 3 761
孤独总比滥情好
孤独总比滥情好 2020-12-14 01:23

I am trying to get factory girl to run with rspec in my rails 4.1.1 app.

Problem is when I run rspec in my command line, i get Failure/Error: vers

3条回答
  •  青春惊慌失措
    2020-12-14 02:03

    There seems to be an issue when using rspec / factory girl with spring.

    Adding:

    config.before(:all) do
      FactoryGirl.reload
    end
    

    in my spec_helper.rb solved the issue.

    Credit: https://github.com/rails/spring/issues/88

    Edit:

    Another way to fix the issue is to manually tell Factory Girl where to load the factory. Add this in your spec_helper:

    FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
    FactoryGirl.find_definitions
    

提交回复
热议问题