Module: FactoryBot::Blueprint
- Defined in:
- lib/factory_bot/blueprint.rb,
lib/factory_bot/blueprint/dsl.rb,
lib/factory_bot/blueprint/version.rb
Overview
A FactoryBot extension for building structured objects using a declarative DSL. First we can build (or extend) a creation plan for a set of objects as Blueprint
, and then we can create actual objects from it.
Blueprint
s can be built using a declarative DSL provided by a core library called Factrey. Each node declaration in the DSL code is automatically correspond to the FactoryBot’s factory. For example, a declaration user(name: 'John')
corresponds to FactoryBot.create(:user, name: 'John')
.
Defined Under Namespace
Classes: DSL
Constant Summary collapse
- VERSION =
"0.4.0"
Class Method Summary collapse
-
.build(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by
build
strategy in FactoryBot. -
.create(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by
create
strategy in FactoryBot. -
.plan(blueprint = nil, ext: nil) { ... } ⇒ Factrey::Blueprint
Entry point to build or extend a Factrey::Blueprint.
Class Method Details
.build(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by build
strategy in FactoryBot. See plan for more details.
63 |
# File 'lib/factory_bot/blueprint.rb', line 63 def build(blueprint = nil, ext: nil, &) = instantiate(:build, blueprint, ext:, &) |
.create(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by create
strategy in FactoryBot. See plan for more details.
71 |
# File 'lib/factory_bot/blueprint.rb', line 71 def create(blueprint = nil, ext: nil, &) = instantiate(:create, blueprint, ext:, &) |
.plan(blueprint = nil, ext: nil) { ... } ⇒ Factrey::Blueprint
Entry point to build or extend a Factrey::Blueprint.
55 |
# File 'lib/factory_bot/blueprint.rb', line 55 def plan(blueprint = nil, ext: nil, &) = Factrey.blueprint(blueprint, ext:, dsl: DSL, &) |