Module: FactoryGirl::Syntax::Generate Private
- Defined in:
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Extends ActiveRecord::Base to provide generation methods for factories.
require 'factory_girl/syntax/generate' FactoryGirl.define do factory :user do name 'Billy Bob' email 'email@example.com' end end # Creates a saved instance without raising (same as saving the result # of FactoryGirl.build) User.generate(name: 'Johnny') # Creates a saved instance and raises when invalid (same as # FactoryGirl.create) User.generate! # Creates an unsaved instance (same as FactoryGirl.build) User.spawn # Creates an instance and yields it to the passed block User.generate do |user| # ...do something with user... end
This syntax was derived from Rick Bradley and Yossef Mendelssohn's object_daddy.
Defined Under Namespace