module Fabrication::Syntax::Make

Extends Fabrication to provide make/make! class methods, which are shortcuts for Fabricate.build/Fabricate.

Usage:

require ‘fabrication/syntax/make’

User.make(:name => ‘Johnny’)

Public Instance Methods

make(*args, &block) click to toggle source
# File lib/fabrication/syntax/make.rb, line 14
def make(*args, &block)
  overrides = Fabrication::Support.extract_options!(args)
  klass = Fabrication::Support.underscore(name).to_sym
  fabricator_name = args.first.is_a?(Symbol) ? "#{klass}_#{args.first}" : klass
  Fabricate.build(fabricator_name, overrides, &block)
end
make!(*args, &block) click to toggle source
# File lib/fabrication/syntax/make.rb, line 21
def make!(*args, &block)
  overrides = Fabrication::Support.extract_options!(args)
  klass = Fabrication::Support.underscore(name).to_sym
  fabricator_name = args.first.is_a?(Symbol) ? "#{klass}_#{args.first}" : klass
  Fabricate(fabricator_name, overrides, &block)
end