factory_bot-blueprint 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/factory_bot/blueprint/version.rb +1 -1
- data/lib/factory_bot/blueprint.rb +13 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfd3f2bba8aa92e21a6e375970c77d48e6634cef9cf39085f5e2648f5415b37
|
4
|
+
data.tar.gz: 55177d1b09287b9b0857614700410db2109333c05b4f5d624028ce15eaa06988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a37fb4bfd61893df1a4301244fd0d3f1bf4c55d4ed3962e62bccfc541a94df9f6b5164fdfc5bfecacd8d6bc42094b21b55c46ae17c59ce0242f573be6ded35
|
7
|
+
data.tar.gz: 78519c9aff90307fc68485847bd7c76bbe635ef1d08c154c596ea1b683f3c9dea4ad4f9e830356fb652f2ae6b29061f84fdb1a4fbb8a56cb280854602f1e64fb
|
@@ -41,32 +41,33 @@ module FactoryBot
|
|
41
41
|
# end
|
42
42
|
#
|
43
43
|
# # Create a set of objects in FactoryBot (with `build` strategy) from the blueprint:
|
44
|
-
#
|
44
|
+
# result, objects = FactoryBot::Blueprint.build(bp)
|
45
45
|
#
|
46
46
|
# # This behaves as:
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
47
|
+
# objects = {}
|
48
|
+
# objects[:blog] = blog = FactoryBot.build(:blog)
|
49
|
+
# objects[gen_random_sym] = FactoryBot.build(:article, title: "Article 1", blog:)
|
50
|
+
# objects[gen_random_sym] = FactoryBot.build(:article, title: "Article 2", blog:)
|
51
|
+
# objects[gen_random_sym] = article3 = FactoryBot.build(:article, title: "Article 3", blog:)
|
52
|
+
# objects[gen_random_sym] = FactoryBot.build(:comment, name: "John", article: article3)
|
53
|
+
# objects[gen_random_sym] = FactoryBot.build(:comment, name: "Doe", article: article3)
|
54
|
+
# result = blog
|
54
55
|
def plan(blueprint = nil, ext: nil, &) = Factrey.blueprint(blueprint, ext:, dsl: DSL, &)
|
55
56
|
|
56
|
-
# Create a set of objects by <code>build</code> strategy in FactoryBot.
|
57
|
+
# Create a set of objects and compute the result by <code>build</code> strategy in FactoryBot.
|
57
58
|
# See {.plan} for more details.
|
58
59
|
# @param blueprint [Factrey::Blueprint, nil]
|
59
60
|
# @param ext [Object] an external object that can be accessed using {DSL#ext} in the DSL
|
60
61
|
# @yield Write Blueprint DSL code here
|
61
|
-
# @return [
|
62
|
+
# @return [(Object, {Symbol => Object})] the result and the created objects
|
62
63
|
def build(blueprint = nil, ext: nil, &) = instantiate(:build, blueprint, ext:, &)
|
63
64
|
|
64
|
-
# Create a set of objects by <code>create</code> strategy in FactoryBot.
|
65
|
+
# Create a set of objects and compute the result by <code>create</code> strategy in FactoryBot.
|
65
66
|
# See {.plan} for more details.
|
66
67
|
# @param blueprint [Factrey::Blueprint, nil]
|
67
68
|
# @param ext [Object] an external object that can be accessed using {DSL#ext} in the DSL
|
68
69
|
# @yield Write Blueprint DSL code here
|
69
|
-
# @return [
|
70
|
+
# @return [(Object, {Symbol => Object})] the result and the created objects
|
70
71
|
def create(blueprint = nil, ext: nil, &) = instantiate(:create, blueprint, ext:, &)
|
71
72
|
|
72
73
|
# @!visibility private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot-blueprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yubrot
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.3.0
|
41
41
|
description: |
|
42
42
|
FactoryBot::Blueprint is a FactoryBot extension for building structured objects using a declarative DSL.
|
43
43
|
On the DSL, the factories defined in FactoryBot can be used without any additional configuration.
|