Module: TestDummy::TestHelper

Defined in:
lib/test_dummy/test_helper.rb

Instance Method Summary collapse

Instance Method Details

#dummy(scope, options = { }) ⇒ Object Also known as: a, an, one_of



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/test_dummy/test_helper.rb', line 2

def dummy(scope, options = { })
  instance = scope.respond_to?(:build) ? scope.build(options) : scope.new(options)

  if (block_given?)
    yield(instance)
  end
  
  instance.dummy!
  
  instance.save!
  instance
end