faker_maker 5.0.0 → 5.0.1
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/faker_maker/factory.rb +8 -3
- data/lib/faker_maker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1df64c4c071bb9c9623874c2f266ac6f9dfba54b2ed0f501f58131353833a59e
|
|
4
|
+
data.tar.gz: 6403c0f1990d048fa124564061048dd86b7d4b28b01a9658b44042cc22886a02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d404f4f32d20a046584921e852d45a3b7fe03d2bf7cd955c8cfcfdbd48d29b5c3e9e4341dbe97d87d9c625a75d7d070e82d4d61dad8a4223cb570d3ecf0aff2
|
|
7
|
+
data.tar.gz: e2758709d5f3fac765e34d3216500125420edd6dd89f53143c0329d77a87cf797370fc9b8394ce06db9532aba46ef50ff13beb3e17e631e6e651fa4ba984a2a0
|
data/lib/faker_maker/factory.rb
CHANGED
|
@@ -237,7 +237,9 @@ module FakerMaker
|
|
|
237
237
|
|
|
238
238
|
def assert_only_known_and_optional_attributes_for_chaos( chaos_attr_values )
|
|
239
239
|
chaos_attr_values = chaos_attr_values.map(&:to_sym)
|
|
240
|
-
unknown_attrs = chaos_attr_values - attribute_names
|
|
240
|
+
unknown_attrs = chaos_attr_values - attribute_names.flat_map do |item|
|
|
241
|
+
item.is_a?(Hash) ? item.keys : item
|
|
242
|
+
end
|
|
241
243
|
issue = "Can't build an instance of '#{class_name}' " \
|
|
242
244
|
"setting '#{unknown_attrs.join( ', ' )}', no such attribute(s)"
|
|
243
245
|
raise FakerMaker::NoSuchAttributeError, issue unless unknown_attrs.empty?
|
|
@@ -280,12 +282,15 @@ module FakerMaker
|
|
|
280
282
|
attributes = attr
|
|
281
283
|
.embedded_factories
|
|
282
284
|
.reject { |e| e == embedded_factory }
|
|
283
|
-
.flat_map { |f|
|
|
285
|
+
.flat_map { |f| f.attributes(include_embeddings: false).map(&:name) }
|
|
284
286
|
.then { |excl| attributes.delete_if { |k, _v| excl.include?(k) } }
|
|
285
287
|
|
|
286
288
|
# The object that is being manufactured by the factory.
|
|
287
289
|
# If an embedded factory name is provided, it builds the object using FakerMaker.
|
|
288
|
-
|
|
290
|
+
# Chaos is converted to a boolean so that child factories inherit random chaos
|
|
291
|
+
# behaviour without receiving attribute names meant for the parent.
|
|
292
|
+
embedded_chaos = chaos.is_a?(Array) || chaos.is_a?(String) || chaos.is_a?(Symbol) ? true : chaos
|
|
293
|
+
embedded_factory&.build(attributes:, chaos: embedded_chaos)
|
|
289
294
|
end
|
|
290
295
|
|
|
291
296
|
def instantiate
|
data/lib/faker_maker/version.rb
CHANGED