fabrication 2.23.1 → 2.27.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb03268f2dae8ad098c0c78fee669b1e7334c14ea030f4c699a82a4fa7e79fd7
4
- data.tar.gz: ec4ac22aed152e6f7fb7dbfcbb5fb60f6d8dce60b5d2eff12b544b1088e7d990
3
+ metadata.gz: 96b935d9bd47864641229df13dda6eda91c99ffdf692495edf1c71703d8edc0b
4
+ data.tar.gz: 6b7c6d1c90ecb94b06b8464ea0bcf2127ba5cf28d1a1adac8cad483cb2a8c4f4
5
5
  SHA512:
6
- metadata.gz: 8eb03fd946d25ecc85932f8743c405395106b84d72989c5b6400baa0f969b6ddcfc021cf09b681a62bfd431a76cc75d86d8cb727a2b8c64df42603365975fbd5
7
- data.tar.gz: 5e6489ad45c74381336c412ef0c229af8e2d7f9758a3a0c65605a3fabd959c106c08dd0d7a998ddc1a2d19915a3c021538ff8014e6bcdd57cf1b1b986e4e34cf
6
+ metadata.gz: cb0b172c07aeb2922312926e2fe62cd55f406c098d4b4d4e1c5e19bf38ea965022c1c4aa06a1c16898aa4abf443bef327bf9e48aa177a9e73a446bb568b5b3d9
7
+ data.tar.gz: 45328d26eb07c9be1f95eb0648535233680379a6c014878202cdfd3707eb6fa522cea77d9d2317bd4418458ce58c846e74105300f5f244e8cab95d4001abe85a
data/lib/fabricate.rb CHANGED
@@ -24,13 +24,19 @@ class Fabricate
24
24
  def self.build(name, overrides = {}, &block)
25
25
  fail_if_initializing(name)
26
26
  schematic(name).build(overrides, &block).tap do |object|
27
- Fabrication::Cucumber::Fabrications[name] = object if Fabrication::Config.register_with_steps?
27
+ Fabrication::Config.notifiers.each do |notifier|
28
+ notifier.call(name, object)
29
+ end
28
30
  end
29
31
  end
30
32
 
31
33
  def self.create(name, overrides = {}, &block)
32
34
  fail_if_initializing(name)
33
- schematic(name).fabricate(overrides, &block)
35
+ schematic(name).fabricate(overrides, &block).tap do |object|
36
+ Fabrication::Config.notifiers.each do |notifier|
37
+ notifier.call(name, object)
38
+ end
39
+ end
34
40
  end
35
41
 
36
42
  def self.sequence(name = Fabrication::Sequencer::DEFAULT, start = nil, &block)
@@ -35,7 +35,7 @@ module Fabrication
35
35
  self.fabricator_path = folders
36
36
  end
37
37
 
38
- attr_writer :sequence_start, :register_with_steps
38
+ attr_writer :sequence_start
39
39
 
40
40
  def sequence_start
41
41
  @sequence_start ||= 0
@@ -50,10 +50,6 @@ module Fabrication
50
50
  end
51
51
  alias path_prefixes path_prefix
52
52
 
53
- def register_with_steps?
54
- @register_with_steps ||= nil
55
- end
56
-
57
53
  def generators
58
54
  @generators ||= []
59
55
  end
@@ -69,5 +65,24 @@ module Fabrication
69
65
  def recursion_limit=(limit)
70
66
  @recursion_limit = limit
71
67
  end
68
+
69
+ def register_with_steps=(value)
70
+ puts 'DEPRECATION WARNING: Fabrication::Config.register_with_steps has been ' \
71
+ 'deprecated. Please regenerate your cucumber steps with `rails g fabrication:cucumber_steps'
72
+
73
+ return unless value
74
+
75
+ register_notifier do |name, object|
76
+ Fabrication::Cucumber::Fabrications[name] = object
77
+ end
78
+ end
79
+
80
+ def notifiers
81
+ @notifiers ||= []
82
+ end
83
+
84
+ def register_notifier(&block)
85
+ notifiers.push(block)
86
+ end
72
87
  end
73
88
  end
@@ -54,12 +54,12 @@ module Fabrication
54
54
  end
55
55
 
56
56
  def build_instance_with_constructor_override(callback)
57
- self._instance = instance_eval(&callback)
57
+ self._instance = instance_exec(_transient_attributes, &callback)
58
58
  set_attributes
59
59
  end
60
60
 
61
61
  def build_instance_with_init_callback(callback)
62
- self._instance = _klass.new(*callback.call)
62
+ self._instance = _klass.new(*callback.call(_transient_attributes))
63
63
  set_attributes
64
64
  end
65
65
 
@@ -55,14 +55,16 @@ module Fabrication
55
55
  def load_definitions
56
56
  preinitialize
57
57
  Fabrication::Config.path_prefixes.each do |prefix|
58
- Fabrication::Config.fabricator_paths.each do |folder|
59
- Dir.glob(File.join(prefix.to_s, folder, '**', '*.rb')).sort.each do |file|
60
- load file
58
+ Fabrication::Config.fabricator_paths.each do |path|
59
+ if File.file?(path)
60
+ load path
61
+ else
62
+ Dir.glob(File.join(prefix.to_s, path, '**', '*.rb')).sort.each do |file|
63
+ load file
64
+ end
61
65
  end
62
66
  end
63
67
  end
64
- rescue StandardError => e
65
- raise e
66
68
  ensure
67
69
  freeze
68
70
  end
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.23.1'.freeze
2
+ VERSION = '2.27.0'.freeze
3
3
  end
data/lib/fabrication.rb CHANGED
@@ -64,9 +64,7 @@ def Fabricator(name, options = {}, &block)
64
64
  end
65
65
 
66
66
  def Fabricate(name, overrides = {}, &block)
67
- Fabricate.create(name, overrides, &block).tap do |object|
68
- Fabrication::Cucumber::Fabrications[name] = object if Fabrication::Config.register_with_steps?
69
- end
67
+ Fabricate.create(name, overrides, &block)
70
68
  end
71
69
  # rubocop:enable Naming/MethodName
72
70
 
@@ -1,6 +1,8 @@
1
1
  World(FabricationMethods)
2
2
 
3
- Fabrication::Config.register_with_steps = true
3
+ Fabrication::Config.register_notifier do |name, object|
4
+ Fabrication::Cucumber::Fabrications[name] = object
5
+ end
4
6
 
5
7
  def with_ivars(fabricator)
6
8
  @they = yield fabricator
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabrication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.23.1
4
+ version: 2.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
14
14
  DataMapper, Sequel, or any other Ruby object.
@@ -54,7 +54,14 @@ files:
54
54
  homepage: http://fabricationgem.org
55
55
  licenses:
56
56
  - MIT
57
- metadata: {}
57
+ metadata:
58
+ bug_tracker_uri: https://gitlab.com/fabrication-gem/fabrication/-/issues
59
+ changelog_uri: https://gitlab.com/fabrication-gem/fabrication/-/blob/master/Changelog.markdown
60
+ documentation_uri: https://fabricationgem.org
61
+ homepage_uri: https://fabricationgem.org
62
+ mailing_list_uri: https://groups.google.com/g/fabricationgem
63
+ rubygems_mfa_required: 'true'
64
+ source_code_uri: https://gitlab.com/fabrication-gem/fabrication
58
65
  post_install_message:
59
66
  rdoc_options: []
60
67
  require_paths:
@@ -73,5 +80,5 @@ requirements: []
73
80
  rubygems_version: 3.2.32
74
81
  signing_key:
75
82
  specification_version: 4
76
- summary: Implementing the factory pattern in Ruby so you don't have to.
83
+ summary: Generates object instances for test suites, seed files, etc.
77
84
  test_files: []