How do I use factories from FactoryGirl in rails console

后端 未结 3 461
无人及你
无人及你 2020-12-22 20:39

I am using rails console in the development environment and I want to use factories. How can I get access to them?

I have tried require \"FactoryGirl\"

3条回答
  •  無奈伤痛
    2020-12-22 21:31

    You need to require 'factory_bot_rails', which is the actual gem that's being used by Rails. That gem will include the Factory Bot library, making FactoryBot available.

    You can either do this, or update your Gemfile to require it at startup as in muttonlamb's answer.

提交回复
热议问题