在Rspec测试中扩展FactoryGirl

在Rspec测试中扩展FactoryGirl,rspec,factory-bot,Rspec,Factory Bot,我试图在rspec测试中使用FactoryGirl函数create和build,而不是每次都指定FactoryGirl命名空间:create,而不是FactoryGirl::create 我想我可以通过如下扩展FactoryGirl来做到这一点,但我总是得到一个命名错误 RSpec.configure do |c| c.extend FactoryGirl end describe 'my thing' do it 'should be ok' do obj = create

我试图在rspec测试中使用FactoryGirl函数
create
build
,而不是每次都指定FactoryGirl命名空间:
create
,而不是
FactoryGirl::create

我想我可以通过如下扩展FactoryGirl来做到这一点,但我总是得到一个命名错误

RSpec.configure do |c|
  c.extend FactoryGirl
end

describe 'my thing' do

  it 'should be ok' do
    obj = create :my_factory
  end

end

我能做什么?

建议的方法如下:

RSpec.configure do |config|
  config.include FactoryGirl::Syntax::Methods
end

这在“使用工厂”下有记录。建议的方法如下:

RSpec.configure do |config|
  config.include FactoryGirl::Syntax::Methods
end
这记录在“使用工厂”下