在没有工厂的情况下使用定义

Use define without factory

这是一个工作代码:

FactoryGirl.define do
  factory :address, class: 'Address' do |a|
    #...
  end
end

我想在没有 factoryGirl 的情况下调用方法 define

我试过这个:

include FactoryGirl::Syntax::Methods

define do
  factory :address, class: 'Address' do |a|
    #...
  end
end

我得到一个错误:

NoMethodError: undefined method `define' for main:Object

有什么解决办法吗?

包括 the proper module 将使它起作用(定义 define 的那个):

include FactoryGirl::Syntax::Default