Class: FactoryBot::DefinitionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ledger_sync/test/support/factory_bot.rb

Instance Method Summary collapse

Instance Method Details

#references_many(name, count: 0, factory: nil) ⇒ FactoryBot::Declaration

Helper method of our references_many on resources

Parameters:

  • name (String)
  • factory (String) (defaults to: nil)

    Defaults to name

Returns:

  • (FactoryBot::Declaration)


132
133
134
135
136
137
# File 'lib/ledger_sync/test/support/factory_bot.rb', line 132

def references_many(name, count: 0, factory: nil)
  add_attribute(name) do
    factory ||= name
    FactoryBot.build_list(factory, count)
  end
end

#references_one(name, factory: nil) ⇒ FactoryBot::Declaration

Helper method of our references_one on resources

Parameters:

  • name (String)
  • factory (String) (defaults to: nil)

    Defaults to name

Returns:

  • (FactoryBot::Declaration)


117
118
119
120
121
122
# File 'lib/ledger_sync/test/support/factory_bot.rb', line 117

def references_one(name, factory: nil)
  add_attribute(name) do
    factory ||= name
    FactoryBot.build(factory, **attributes_for(factory))
  end
end