factory_bot 6.5.6 → 6.6.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/GETTING_STARTED.md +20 -0
- data/NEWS.md +14 -0
- data/README.md +1 -3
- data/lib/factory_bot/definition_proxy.rb +1 -1
- data/lib/factory_bot/factory_runner.rb +2 -0
- data/lib/factory_bot/linter.rb +1 -1
- data/lib/factory_bot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: baec274935393ce2b200df3e96b5eea1bdc81955f17eee767c50e1c5538b565b
|
|
4
|
+
data.tar.gz: 662222ee8a0386a18262a5e726a2c6252a96ffc0364d354b1498ff62a333cb8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 463b52e964995323501d4b1017687fb225519db1b9a073dd2289c152ccdbe14ff15eff09f8d602ec299b108a1c777f3682ad6fc4ce65c1fca298e5ba0e5786a4
|
|
7
|
+
data.tar.gz: 699311f5ef386653530ca631fe7f2824da7862073526abd686c18c3e2ba5431b4e67e7fab09e6a5cd1798f69f1a51122ae3ceeeacd0f382ff1f5093d3e97d60b
|
data/GETTING_STARTED.md
CHANGED
|
@@ -2084,6 +2084,26 @@ config.after(:suite) do
|
|
|
2084
2084
|
end
|
|
2085
2085
|
```
|
|
2086
2086
|
|
|
2087
|
+
You can also subscribe to `factory_bot.before_run_factory` to be notified
|
|
2088
|
+
before a factory is run. This is useful for building a factory call stack when
|
|
2089
|
+
debugging deeply nested associations:
|
|
2090
|
+
|
|
2091
|
+
```ruby
|
|
2092
|
+
factory_call_stack = []
|
|
2093
|
+
|
|
2094
|
+
ActiveSupport::Notifications.subscribe("factory_bot.before_run_factory") do |name, start, finish, id, payload|
|
|
2095
|
+
factory_call_stack.push(payload[:name])
|
|
2096
|
+
end
|
|
2097
|
+
|
|
2098
|
+
ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |name, start, finish, id, payload|
|
|
2099
|
+
factory_call_stack.pop
|
|
2100
|
+
end
|
|
2101
|
+
```
|
|
2102
|
+
|
|
2103
|
+
The payload for `factory_bot.before_run_factory` contains the same keys as
|
|
2104
|
+
`factory_bot.run_factory`: `:name`, `:strategy`, `:traits`, `:overrides`, and
|
|
2105
|
+
`:factory`.
|
|
2106
|
+
|
|
2087
2107
|
Another example could involve tracking the attributes and traits that factories are compiled with. If you're using RSpec, you could add `before(:suite)` and `after(:suite)` blocks that subscribe to `factory_bot.compile_factory` notifications:
|
|
2088
2108
|
|
|
2089
2109
|
```ruby
|
data/NEWS.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# News
|
|
2
2
|
|
|
3
|
+
## 6.6.0 (May 4, 2026)
|
|
4
|
+
|
|
5
|
+
* Feat: Added `factory_bot.before_run_factory` instrumentation event
|
|
6
|
+
* Add workflow to prepare a release PR by @neilvcarvalho in [#1816](https://github.com/thoughtbot/factory_bot/pull/1816)
|
|
7
|
+
* Add gem release workflow with GitHub release notes from changelog by @neilvcarvalho in [#1815](https://github.com/thoughtbot/factory_bot/pull/1815)
|
|
8
|
+
* Require MFA for gem pushes by @MatheusRich in [#1814](https://github.com/thoughtbot/factory_bot/pull/1814)
|
|
9
|
+
* Add `factory_bot.before_run_factory` instrumentation event by @hammadxcm in [#1795](https://github.com/thoughtbot/factory_bot/pull/1795)
|
|
10
|
+
* Remove CodeClimate badge from README by @hammadxcm in [#1794](https://github.com/thoughtbot/factory_bot/pull/1794)
|
|
11
|
+
* Update CI matrix by @berkos in [#1793](https://github.com/thoughtbot/factory_bot/pull/1793)
|
|
12
|
+
* Bump actions/checkout from 5 to 6 by @app/dependabot in [#1791](https://github.com/thoughtbot/factory_bot/pull/1791)
|
|
13
|
+
* Ensure linting transactions don't interfere with ActiveRecord lifecycle by @NikolasPilavakis in [#1790](https://github.com/thoughtbot/factory_bot/pull/1790)
|
|
14
|
+
* removes @doodlingdev by @DoodlingDev in [#1789](https://github.com/thoughtbot/factory_bot/pull/1789)
|
|
15
|
+
* DefinitionProxy#method_missing: Forward given block to #association by @grekko in [#1579](https://github.com/thoughtbot/factory_bot/pull/1579)
|
|
16
|
+
|
|
3
17
|
## 6.5.6 (October 22, 2025)
|
|
4
18
|
|
|
5
19
|
* Fix: Enforce association override precedence over trait foreign keys by @JinOketani in [#1768](https://github.com/thoughtbot/factory_bot/pull/1768)
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# factory_bot
|
|
2
2
|
|
|
3
|
-
[![Build Status][ci-image]][ci] [![
|
|
3
|
+
[![Build Status][ci-image]][ci] [![Gem Version][version-image]][version]
|
|
4
4
|
|
|
5
5
|
factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
|
|
6
6
|
|
|
@@ -93,8 +93,6 @@ We are [available for hire][hire].
|
|
|
93
93
|
|
|
94
94
|
[ci-image]: https://github.com/thoughtbot/factory_bot/actions/workflows/build.yml/badge.svg?branch=main
|
|
95
95
|
[ci]: https://github.com/thoughtbot/factory_bot/actions?query=workflow%3ABuild+branch%3Amain
|
|
96
|
-
[grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot/badges/gpa.svg
|
|
97
|
-
[grade]: https://codeclimate.com/github/thoughtbot/factory_bot
|
|
98
96
|
[version-image]: https://badge.fury.io/rb/factory_bot.svg
|
|
99
97
|
[version]: https://badge.fury.io/rb/factory_bot
|
|
100
98
|
[hound-badge-image]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
|
|
@@ -94,7 +94,7 @@ module FactoryBot
|
|
|
94
94
|
if association_options.nil?
|
|
95
95
|
__declare_attribute__(name, block)
|
|
96
96
|
elsif __valid_association_options?(association_options)
|
|
97
|
-
association(name, association_options)
|
|
97
|
+
association(name, association_options, &block)
|
|
98
98
|
else
|
|
99
99
|
raise NoMethodError.new(<<~MSG)
|
|
100
100
|
undefined method '#{name}' in '#{@definition.name}' factory
|
|
@@ -25,6 +25,8 @@ module FactoryBot
|
|
|
25
25
|
factory: factory
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
ActiveSupport::Notifications.instrument("factory_bot.before_run_factory", instrumentation_payload)
|
|
29
|
+
|
|
28
30
|
ActiveSupport::Notifications.instrument("factory_bot.run_factory", instrumentation_payload) do
|
|
29
31
|
factory.run(runner_strategy, @overrides, &block)
|
|
30
32
|
end
|
data/lib/factory_bot/linter.rb
CHANGED
data/lib/factory_bot/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: factory_bot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josh Clayton
|
|
@@ -252,6 +252,7 @@ licenses:
|
|
|
252
252
|
- MIT
|
|
253
253
|
metadata:
|
|
254
254
|
changelog_uri: https://github.com/thoughtbot/factory_bot/blob/main/NEWS.md
|
|
255
|
+
rubygems_mfa_required: 'true'
|
|
255
256
|
rdoc_options: []
|
|
256
257
|
require_paths:
|
|
257
258
|
- lib
|
|
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
266
267
|
- !ruby/object:Gem::Version
|
|
267
268
|
version: '0'
|
|
268
269
|
requirements: []
|
|
269
|
-
rubygems_version:
|
|
270
|
+
rubygems_version: 4.0.3
|
|
270
271
|
specification_version: 4
|
|
271
272
|
summary: factory_bot provides a framework and DSL for defining and using model instance
|
|
272
273
|
factories.
|