Ruby 使用无工厂定义

Ruby 使用无工厂定义,ruby,include,factory-bot,Ruby,Include,Factory Bot,以下是工作代码: FactoryGirl.define do factory :address, class: 'Address' do |a| #... end end 我想调用方法define,而不调用factoryGirl 我试过这个: include FactoryGirl::Syntax::Methods define do factory :address, class: 'Address' do |a| #... end end 我得到一个错误

以下是工作代码:

FactoryGirl.define do
  factory :address, class: 'Address' do |a|
    #...
  end
end
我想调用方法
define
,而不调用
factoryGirl

我试过这个:

include FactoryGirl::Syntax::Methods

define do
  factory :address, class: 'Address' do |a|
    #...
  end
end
我得到一个错误:

NoMethodError: undefined method `define' for main:Object
是否有任何解决方案?

包括将使其工作(其中定义了
定义
):

include FactoryGirl::Syntax::Default