factory_bot_instrumentation 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/app/controllers/factory_bot/instrumentation/root_controller.rb +5 -2
- data/factory_bot_instrumentation.gemspec +2 -0
- data/lib/factory_bot/instrumentation/engine.rb +10 -5
- data/lib/factory_bot/instrumentation/version.rb +1 -1
- data/lib/factory_bot_instrumentation.rb +1 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df9495f96882f162c18ca1c8467d09c34d8dc40981ed1a7ba541a7d5200867a9
|
4
|
+
data.tar.gz: 2ae4e05a4dbd3e729d56ffbfeafb2c14aeef6b6a8e825a6b94023bb6fa379823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c598dcbc2cf1cfc4f7e7c6d9a1e0389f7c9583e9208ae008db35cf320ba740232a9038fb6c00b92b06d95ca5483fee5663b88e70b39c6e7371624494d337f21f
|
7
|
+
data.tar.gz: dd88ab7d48335f79c874005ea50ee76a6878af89cc3ebbb5333ade70059f084654c20ae83a2200d1d6c2730ced8e58859a4358c8934703f19fa2dfe5f29e766b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 1.0.2
|
2
|
+
|
3
|
+
* When used in combination with the `factory_bot_rails` gem (>= 6.0) we do not
|
4
|
+
force a `FactoryBot.reload` at Rails engine initialization as it breaks with
|
5
|
+
an `FactoryBot::DuplicateDefinitionError` (#14)
|
6
|
+
|
7
|
+
### 1.0.1
|
8
|
+
|
9
|
+
* Added a retry logic to the FactoryBot reloading on the POST/create endpoint
|
10
|
+
in order to handle parallel requests properly (#13)
|
11
|
+
|
1
12
|
### 1.0.0
|
2
13
|
|
3
14
|
* Bundler >= 2.3 is from now on required as minimal version (#12)
|
@@ -37,8 +37,11 @@ module FactoryBot
|
|
37
37
|
#
|
38
38
|
# The result is the API v1 representation of the created entity.
|
39
39
|
def create
|
40
|
-
# Reload the factories to improve the test development experience
|
41
|
-
|
40
|
+
# Reload the factories to improve the test development experience.
|
41
|
+
# In parallel request conditions this may lead to +Factory already
|
42
|
+
# registered+ errors as this call is not thread safe as it seems,
|
43
|
+
# so we retry it multiple times.
|
44
|
+
with_retries(max_tries: 15) { FactoryBot.reload }
|
42
45
|
# Call the factory construction with the user given parameters
|
43
46
|
entity = FactoryBot.create(*factory_params)
|
44
47
|
# Render the resulting entity with the configured rendering block
|
@@ -35,10 +35,12 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_runtime_dependency 'factory_bot', '~> 6.2'
|
37
37
|
spec.add_runtime_dependency 'rails', '>= 5.2'
|
38
|
+
spec.add_runtime_dependency 'retries', '>= 0.0.5'
|
38
39
|
|
39
40
|
spec.add_development_dependency 'appraisal', '~> 2.4'
|
40
41
|
spec.add_development_dependency 'bundler', '~> 2.3'
|
41
42
|
spec.add_development_dependency 'countless', '~> 1.1'
|
43
|
+
spec.add_development_dependency 'factory_bot_rails', '~> 6.2'
|
42
44
|
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
43
45
|
spec.add_development_dependency 'railties', '>= 5.2'
|
44
46
|
spec.add_development_dependency 'rspec-rails', '~> 5.1'
|
@@ -7,11 +7,16 @@ module FactoryBot
|
|
7
7
|
isolate_namespace FactoryBot::Instrumentation
|
8
8
|
|
9
9
|
# Fill in some dynamic settings (application related)
|
10
|
-
initializer 'factory_bot_instrumentation.config' do
|
11
|
-
# Ensure the FactoryBot gem loads its factories to ensure they are
|
12
|
-
#
|
13
|
-
#
|
14
|
-
FactoryBot
|
10
|
+
initializer 'factory_bot_instrumentation.config' do |app|
|
11
|
+
# Ensure the FactoryBot gem loads its factories to ensure they are also
|
12
|
+
# available in the rails console and other places in the app and not
|
13
|
+
# only via instrumentation frontend. We skip this step as in
|
14
|
+
# combination with the +factory_bot_rails+ gem (>=6.0) the FactoryBot
|
15
|
+
# initializing occurs after the Rails application initializing, which
|
16
|
+
# leads to +FactoryBot::DuplicateDefinitionError+s.
|
17
|
+
initializer_names = app.initializers.map(&:name).map(&:to_s)
|
18
|
+
FactoryBot.reload \
|
19
|
+
if initializer_names.grep(/^factory_bot\./).count.zero?
|
15
20
|
|
16
21
|
FactoryBot::Instrumentation.configure do |conf|
|
17
22
|
# Set the application name dynamically
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot_instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hermann Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: retries
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.5
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: appraisal
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,20 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '1.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: factory_bot_rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '6.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '6.2'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: guard-rspec
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|