factory_bot_instrumentation 2.1.0 → 2.2.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 +4 -4
- data/.rubocop.yml +4 -34
- data/CHANGELOG.md +4 -0
- data/Envfile +1 -0
- data/LICENSE +1 -1
- data/README.md +9 -9
- data/app/assets/javascripts/factory_bot_instrumentation/create.js +2 -2
- data/app/assets/javascripts/factory_bot_instrumentation/hooks.js +1 -1
- data/app/controllers/factory_bot/instrumentation/application_controller.rb +2 -2
- data/app/controllers/factory_bot/instrumentation/root_controller.rb +0 -4
- data/config/instrumentation.yml +1 -1
- data/lib/factory_bot/instrumentation/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: 166d24c0a99e8dd9dca1a06a195cdc9c9a89d2ec4aca5eeb1978e8bc9168bbcb
|
|
4
|
+
data.tar.gz: 8dbd9b962528fdb0f033a508dee1c63dbe4cd0eed0f564384bd74aad44e7a1c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba0e5b5ca4302c6025ca5b0247aac5bdca259999e58954f6f8e3fcf32e0ed998848138a75c2ec665f6398b1e57f0e0355d51d030ee591321077457c55873ff60
|
|
7
|
+
data.tar.gz: 63f212c7d2ef904b0bd82cac15a374a3c1f3f478c93dbf4ca6f157c0e2ad242da029011a353dba103788b826a29b1185938e3559fc441b37f1b71b8932e86659
|
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://potpourri.hausgold.de/config/rubocop.yml
|
|
3
|
+
- https://potpourri.hausgold.de/config/rubocop-gem.yml
|
|
4
|
+
|
|
1
5
|
plugins:
|
|
2
6
|
- rubocop-rspec
|
|
3
7
|
- rubocop-rails
|
|
@@ -5,9 +9,6 @@ plugins:
|
|
|
5
9
|
Rails:
|
|
6
10
|
Enabled: true
|
|
7
11
|
|
|
8
|
-
Style/Documentation:
|
|
9
|
-
Enabled: true
|
|
10
|
-
|
|
11
12
|
AllCops:
|
|
12
13
|
NewCops: enable
|
|
13
14
|
SuggestExtensions: false
|
|
@@ -21,43 +22,12 @@ AllCops:
|
|
|
21
22
|
- gemfiles/**/*
|
|
22
23
|
- spec/dummy/**/*
|
|
23
24
|
|
|
24
|
-
Metrics/BlockLength:
|
|
25
|
-
Exclude:
|
|
26
|
-
- Rakefile
|
|
27
|
-
- '*.gemspec'
|
|
28
|
-
- spec/**/*.rb
|
|
29
|
-
- '**/*.rake'
|
|
30
|
-
- doc/**/*.rb
|
|
31
|
-
|
|
32
|
-
# MFA is not yet enabled for our gems yet.
|
|
33
|
-
Gemspec/RequireMFA:
|
|
34
|
-
Enabled: false
|
|
35
|
-
|
|
36
|
-
# We stay with the original Ruby Style Guide recommendation.
|
|
37
|
-
Layout/LineLength:
|
|
38
|
-
Max: 80
|
|
39
|
-
|
|
40
|
-
# Document all the things.
|
|
41
|
-
Style/DocumentationMethod:
|
|
42
|
-
Enabled: true
|
|
43
|
-
RequireForNonPublicMethods: true
|
|
44
|
-
|
|
45
25
|
# It's a deliberate idiom in RSpec.
|
|
46
26
|
# See: https://github.com/bbatsov/rubocop/issues/4222
|
|
47
27
|
Lint/AmbiguousBlockAssociation:
|
|
48
28
|
Exclude:
|
|
49
29
|
- "spec/**/*"
|
|
50
30
|
|
|
51
|
-
# Because +expect_any_instance_of().to have_received()+ is not
|
|
52
|
-
# supported with the +with(hash_including)+ matchers
|
|
53
|
-
RSpec/MessageSpies:
|
|
54
|
-
EnforcedStyle: receive
|
|
55
|
-
|
|
56
|
-
# Because nesting makes sense here to group the feature tests
|
|
57
|
-
# more effective. This increases maintainability.
|
|
58
|
-
RSpec/NestedGroups:
|
|
59
|
-
Max: 4
|
|
60
|
-
|
|
61
31
|
# Disable regular Rails spec paths.
|
|
62
32
|
Rails/FilePath:
|
|
63
33
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
|
4
4
|
|
|
5
|
+
### 2.2.0 (19 December 2025)
|
|
6
|
+
|
|
7
|
+
* Migrated to a shared Rubocop configuration for HAUSGOLD gems ([#37](https://github.com/hausgold/factory_bot_instrumentation/pull/37))
|
|
8
|
+
|
|
5
9
|
### 2.1.0 (23 October 2025)
|
|
6
10
|
|
|
7
11
|
* Added support for Rails 8.1 ([#35](https://github.com/hausgold/factory_bot_instrumentation/pull/35))
|
data/Envfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -73,8 +73,8 @@ application is working as expected. Whoop. A failure happens on the frontend
|
|
|
73
73
|
and a lot of tests fail due to the root cause that an entity was not
|
|
74
74
|
deleted/recreated.
|
|
75
75
|
|
|
76
|
-
A better solution
|
|
77
|
-
entity may be deleted in an isolated manner, due to a random seed.
|
|
76
|
+
A better solution would be a dynamic seed generation per test case. So an
|
|
77
|
+
entity may be deleted in an isolated manner, due to a random seed. That's even
|
|
78
78
|
better than looking for a statically seeded entity on a list for example,
|
|
79
79
|
because you can now just focus on the single entry which was dynamically
|
|
80
80
|
generated for your insolated test case.
|
|
@@ -82,7 +82,7 @@ generated for your insolated test case.
|
|
|
82
82
|
Another use case for dynamic seeds are explorative testers. They could benefit
|
|
83
83
|
from the entities your factories are already generating. But on canary, or
|
|
84
84
|
production like environments they are not able to access an Rails console to
|
|
85
|
-
trigger the factory_bot factories.
|
|
85
|
+
trigger the factory_bot factories. That's where `factory_bot_instrumentation`
|
|
86
86
|
comes in.
|
|
87
87
|
|
|
88
88
|
## Usage
|
|
@@ -144,7 +144,7 @@ let(:user_with_many_friends) { create :user, :with_friends, friends_amount: 5 }
|
|
|
144
144
|
|
|
145
145
|
With the Instrumentation engine you allow external users to trigger your
|
|
146
146
|
factories the same way via an API (HTTP request) or with preconfigured
|
|
147
|
-
scenarios via an easy to use frontend.
|
|
147
|
+
scenarios via an easy to use frontend. That's it.
|
|
148
148
|
|
|
149
149
|
### Configuration
|
|
150
150
|
|
|
@@ -186,7 +186,7 @@ default: &default
|
|
|
186
186
|
overwrite: {}
|
|
187
187
|
|
|
188
188
|
- name: User with a single friend named Bob
|
|
189
|
-
desc: Create a new user with a single friend
|
|
189
|
+
desc: Create a new user with a single friend whose name is Bob.
|
|
190
190
|
factory: :user
|
|
191
191
|
traits:
|
|
192
192
|
- :confirmed
|
|
@@ -346,7 +346,7 @@ end
|
|
|
346
346
|
### API
|
|
347
347
|
|
|
348
348
|
The Instrumentation engine comes with a single API endpoint which allows you to
|
|
349
|
-
trigger your factory_bot factories with traits and overwrites.
|
|
349
|
+
trigger your factory_bot factories with traits and overwrites. That's just as
|
|
350
350
|
simple as it sounds.
|
|
351
351
|
|
|
352
352
|
The endpoint is at the same path as you mounted the engine. Say you mounted the
|
|
@@ -580,7 +580,7 @@ here:
|
|
|
580
580
|
|
|
581
581
|
##### postCreateError
|
|
582
582
|
|
|
583
|
-
In case you want to perform some magic after an error
|
|
583
|
+
In case you want to perform some magic after an error occurred, you can use
|
|
584
584
|
the `postCreateError` hook. You can access the output options and the
|
|
585
585
|
runtime payload with all its data, but changes to them won't take effect
|
|
586
586
|
because this hook is triggered after the error is rendered. The `payload`
|
|
@@ -673,7 +673,7 @@ An example block could look like this:
|
|
|
673
673
|
{
|
|
674
674
|
cb(null, `
|
|
675
675
|
<div class="alert alert-danger" role="alert">
|
|
676
|
-
An unexpected error
|
|
676
|
+
An unexpected error occurred.
|
|
677
677
|
</div>
|
|
678
678
|
<pre id="data">${output}</pre>
|
|
679
679
|
${window.utils.clipboardButton('data')}
|
|
@@ -725,7 +725,7 @@ custom functionality like blocks or complete custom Instrumentation pages. Just
|
|
|
725
725
|
create `app/views/factory_bot_instrumentation/_styles.html.erb` inside your
|
|
726
726
|
application. The file could look like this:
|
|
727
727
|
|
|
728
|
-
```
|
|
728
|
+
```html
|
|
729
729
|
<link rel="stylesheet"
|
|
730
730
|
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/dark.min.css"
|
|
731
731
|
integrity="sha256-GVo4WKmO61/tVmRyEKLvRm2Nnq7mdFCaOim/9HbNpaM="
|
|
@@ -12,8 +12,8 @@ window.CreateForm = CreateForm = function()
|
|
|
12
12
|
{
|
|
13
13
|
window.utils.waterfallWithHooks({
|
|
14
14
|
data: {
|
|
15
|
-
alert: `An unexpected error
|
|
16
|
-
while generating your new entity. This
|
|
15
|
+
alert: `An unexpected error occurred. Looks like something went wrong
|
|
16
|
+
while generating your new entity. This might be a bug, or an
|
|
17
17
|
unexpected feature. It could be a temporary issue. When this
|
|
18
18
|
is persistent contact your friendly API Instrumentation
|
|
19
19
|
administrator.`,
|
|
@@ -106,7 +106,7 @@ window.hooks = {
|
|
|
106
106
|
// }
|
|
107
107
|
preCreateError: [],
|
|
108
108
|
|
|
109
|
-
// In case you want to perform some magic after an error
|
|
109
|
+
// In case you want to perform some magic after an error occurred, you can use
|
|
110
110
|
// the +postCreateError+ hook. You can access the output options and the
|
|
111
111
|
// runtime payload with all its data, but changes to them won't take effect
|
|
112
112
|
// because this hook is triggered after the error is rendered. The +payload+
|
|
@@ -42,7 +42,7 @@ module FactoryBot
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Unfortunately +Rails.configuration.instrumentation+ is only read once
|
|
45
|
-
# and do not hot-reload on changes.
|
|
45
|
+
# and do not hot-reload on changes. That's why we read this file manually
|
|
46
46
|
# to get always a fresh state.
|
|
47
47
|
#
|
|
48
48
|
# @return [Hash{String => Mixed}] the instrumentation scenarios
|
|
@@ -66,7 +66,7 @@ module FactoryBot
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
# Map all the configured scenario groups to a
|
|
69
|
+
# Map all the configured scenario groups to a usable hash.
|
|
70
70
|
#
|
|
71
71
|
# @return [Hash{Regexp => String}] the group mapping
|
|
72
72
|
def groups
|
|
@@ -51,9 +51,6 @@ module FactoryBot
|
|
|
51
51
|
# a valid FactoryBot options set.
|
|
52
52
|
#
|
|
53
53
|
# @return [Array<Mixed>] the FactoryBot options
|
|
54
|
-
#
|
|
55
|
-
# rubocop:disable Metrics/MethodLength -- because of the Rails version
|
|
56
|
-
# handling
|
|
57
54
|
def factory_params
|
|
58
55
|
data = params.permit(:factory, traits: [])
|
|
59
56
|
|
|
@@ -70,7 +67,6 @@ module FactoryBot
|
|
|
70
67
|
{ **overwrite }
|
|
71
68
|
]
|
|
72
69
|
end
|
|
73
|
-
# rubocop:enable Metrics/MethodLength
|
|
74
70
|
end
|
|
75
71
|
end
|
|
76
72
|
end
|
data/config/instrumentation.yml
CHANGED
|
@@ -27,7 +27,7 @@ default: &default
|
|
|
27
27
|
overwrite: {}
|
|
28
28
|
|
|
29
29
|
- name: User with a single friend named Bob
|
|
30
|
-
desc: Create a new user with a single friend
|
|
30
|
+
desc: Create a new user with a single friend whose name is Bob.
|
|
31
31
|
factory: :user
|
|
32
32
|
traits:
|
|
33
33
|
- :confirmed
|