Module: FactoryBot::Blueprint
- Defined in:
- lib/factory_bot/blueprint.rb,
lib/factory_bot/blueprint/dsl.rb,
lib/factory_bot/blueprint/methods.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 Factrey::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
Constant Summary collapse
- VERSION =
"0.5.0"
Class Method Summary collapse
-
.build(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by
build
build strategy in FactoryBot. -
.build_stubbed(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by
build_stubbed
build strategy in FactoryBot. -
.create(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by
create
build 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
build strategy in FactoryBot. See plan for more details.
67 |
# File 'lib/factory_bot/blueprint.rb', line 67 def build(blueprint = nil, ext: nil, &) = instantiate(:build, blueprint, ext:, &) |
.build_stubbed(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by build_stubbed
build strategy in FactoryBot. See plan for more details.
75 |
# File 'lib/factory_bot/blueprint.rb', line 75 def build_stubbed(blueprint = nil, ext: nil, &) = instantiate(:build_stubbed, blueprint, ext:, &) |
.create(blueprint = nil, ext: nil) { ... } ⇒ Hash{Symbol => Object}
Create a set of objects by create
build strategy in FactoryBot. See plan for more details.
83 |
# File 'lib/factory_bot/blueprint.rb', line 83 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.
59 |
# File 'lib/factory_bot/blueprint.rb', line 59 def plan(blueprint = nil, ext: nil, &) = Factrey.blueprint(blueprint, ext:, dsl: DSL, &) |