fabrication 2.25.0 → 2.28.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: 25bf46c387fd321a6b7fb9f35b7a67862ced410dd318ad2c29a0bca8dd61479b
4
- data.tar.gz: 367a2d9d5bc7213443a4de423447c99f9141e92c47fecc5ea0092df2b7821dbe
3
+ metadata.gz: df854c441daf0accdb476682c98e8dcc2fab18fe239d182ccfe2946e16995921
4
+ data.tar.gz: d6cf1bfa72594c9255243643eed956f97af1fd976bb8768fe458410f54e4d1dd
5
5
  SHA512:
6
- metadata.gz: 3ad4fc489704de95e48fd156f043ef22638d5e910e1d684db9e09798e9eb2064003056616cfbd08ec944aab4e024ad65f6bdca6d993e6f5a04aaa395bb48cf2c
7
- data.tar.gz: 2f1cbf6bc060c00578234773534148eac605271f32e08b636aa873e232bc532da3e531c301830577dd1a2842a9592d4976485226d6804296110fea358a923c01
6
+ metadata.gz: 4783af273421b7799092a0bcc75c86a66d8f85f22a98d18354935010ccabc4a8fd32aa0eef5c814bab7257ff29cfef8db3e58160016d04a6f77b1480b92a80f9
7
+ data.tar.gz: 6fdec94bac094143b78d8135b56219c8e2faaa9136035fc1dcd309e0d7b44978991c12664ae422722debadb13ffe4c2396cde01e3e384c495d08d29fb869fa8b
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
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.25.0'.freeze
2
+ VERSION = '2.28.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
@@ -33,6 +33,8 @@ module Fabrication
33
33
  end
34
34
  rescue StandardError
35
35
  # no table? no problem!
36
+ rescue LoadError
37
+ # cannot find model file. This means it was already destroyed, so just continue.
36
38
  end
37
39
  end
38
40
  end
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.25.0
4
+ version: 2.28.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: 2022-01-28 00:00:00.000000000 Z
11
+ date: 2022-03-29 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: []