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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89384db0522f5262709df19f70d39b08af7c7eadd26e252560590e536a83d817
4
- data.tar.gz: 2be455b31165be74a8a2fd2f6008d6424287c9aeefbef4b4499d2b061d70d374
3
+ metadata.gz: cbfd3f2bba8aa92e21a6e375970c77d48e6634cef9cf39085f5e2648f5415b37
4
+ data.tar.gz: 55177d1b09287b9b0857614700410db2109333c05b4f5d624028ce15eaa06988
5
5
  SHA512:
6
- metadata.gz: c1b9a4ccf44e9dcef033bcbe83180f3f34b5650f53f033e73d5bb2c157ada4b8fdf10a98e0ec963c585f689c913252cdf5c270be018af4eb72c101f5c1af696a
7
- data.tar.gz: 7b16fa3b35e416ae46f7e9db4bebec026a387cb2556ad670e96e6c6c5d2de3168403a39340d50436d19b05d22cc943a1dc78cecef8c4dcec3f7a1f93c5e831be
6
+ metadata.gz: b4a37fb4bfd61893df1a4301244fd0d3f1bf4c55d4ed3962e62bccfc541a94df9f6b5164fdfc5bfecacd8d6bc42094b21b55c46ae17c59ce0242f573be6ded35
7
+ data.tar.gz: 78519c9aff90307fc68485847bd7c76bbe635ef1d08c154c596ea1b683f3c9dea4ad4f9e830356fb652f2ae6b29061f84fdb1a4fbb8a56cb280854602f1e64fb
@@ -2,6 +2,6 @@
2
2
 
3
3
  module FactoryBot
4
4
  module Blueprint
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -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
- # instance = FactoryBot::Blueprint.build(bp)
44
+ # result, objects = FactoryBot::Blueprint.build(bp)
45
45
  #
46
46
  # # This behaves as:
47
- # instance = {}
48
- # instance[:blog] = blog = FactoryBot.build(:blog)
49
- # instance[gen_random_sym] = FactoryBot.build(:article, title: "Article 1", blog:)
50
- # instance[gen_random_sym] = FactoryBot.build(:article, title: "Article 2", blog:)
51
- # instance[gen_random_sym] = article3 = FactoryBot.build(:article, title: "Article 3", blog:)
52
- # instance[gen_random_sym] = FactoryBot.build(:comment, name: "John", article: article3)
53
- # instance[gen_random_sym] = FactoryBot.build(:comment, name: "Doe", article: article3)
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 [Hash{Symbol => Object}]
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 [Hash{Symbol => Object}]
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.1.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-22 00:00:00.000000000 Z
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.1.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.1.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.