Method: Factory.create
- Defined in:
- lib/factory_girl/factory.rb
.create(name, overrides = {}) ⇒ Object
Generates, saves, and returns an instance from this factory. Attributes can be individually overridden by passing in a Hash of attribute => value pairs.
Instances are saved using the save!
method, so ActiveRecord models will raise ActiveRecord::RecordInvalid exceptions for invalid attribute sets.
Arguments:
-
name:
Symbol
orString
The name of the factory that should be used. -
overrides:
Hash
Attributes to overwrite for this instance.
Returns: Object
A saved instance of the class this factory generates, with generated attributes assigned.
236 237 238 |
# File 'lib/factory_girl/factory.rb', line 236 def self.create (name, overrides = {}) factory_by_name(name).run(Proxy::Create, overrides) end |