Module: Gonzales::TestHelper

Defined in:
lib/gonzales/test_helper.rb

Overview

Gonzales::TestHelper

Helper to be used when writing tests when you use Gonzales

Instance Method Summary collapse

Instance Method Details

#speedy(factory_name, *options) ⇒ Object

returns a created record to be used in tests

speedy will return the record from the database if it alreday exists in the test database. If not it will call FactoryGirl to instantiate the record.

Arguments

* factory_name - Name of the factory or the alias specified in the gonzales file
* options - will be passed to FactoryGirl if the factory does not exist in the test database.
  Note!! options will not be passed to Gonzales.

Example

setup do
  @person = speedy :person
end


47
48
49
# File 'lib/gonzales/test_helper.rb', line 47

def speedy(factory_name, *options)
  Collection.entity(factory_name) || Adapter.create(factory_name, *options)
end