使用define而不用工厂

时间:2017-02-24 13:28:04

标签: ruby include factory-bot

这是一个有效的代码:

Public Property MemberValue as Object
    Get
        Static value as Object = Nothing

        If (value is Nothing) Then
            value = LoadMember()
        End If

        Return value
    End Get
End Property

我想在没有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

有没有解决方案?

1 个答案:

答案 0 :(得分:1)

包含the proper module会使其有效(定义{{​​1}}的那个):

define