factory_bot_rails 6.2.0 → 6.5.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/CONTRIBUTING.md +1 -1
- data/NEWS.md +55 -0
- data/README.md +33 -10
- data/lib/factory_bot_rails/factory_validator.rb +23 -0
- data/lib/factory_bot_rails/file_fixture_support.rb +9 -0
- data/lib/factory_bot_rails/generators/null_generator.rb +1 -1
- data/lib/factory_bot_rails/railtie.rb +21 -0
- data/lib/factory_bot_rails/version.rb +3 -0
- data/lib/generators/factory_bot.rb +1 -1
- data/lib/rails/projections.json +26 -0
- metadata +73 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57f9bdcf6302512e51ca8a0d833f74061aec2f9546be0ab0a7c55af6e414e4d
|
4
|
+
data.tar.gz: dee564c6e125c20d959b9ff77983413a6d4b834c7efcdfdde699a821cb19cc50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 806fc74737f9fe90bd0463c8d44160f89d0ae407df0d0149cac0b901cab0a47513a5ad45e790eb3cbb4c73e0e64b993cf21469c0fb015514242a6ac023242122
|
7
|
+
data.tar.gz: f41886fd5253fa81e93bb652c1e6d155efdcc370f6b68cee949be59e09191c4a0766dd2b983d600e5c8988105f47e16a1d55c91d3826d63444e69a786ccd37db
|
data/CONTRIBUTING.md
CHANGED
@@ -35,5 +35,5 @@ Some things that will increase the chance that your pull request is accepted:
|
|
35
35
|
* Follow our [style guide][style].
|
36
36
|
* Write a [good commit message][commit].
|
37
37
|
|
38
|
-
[style]: https://github.com/thoughtbot/guides/tree/
|
38
|
+
[style]: https://github.com/thoughtbot/guides/tree/main/general
|
39
39
|
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
data/NEWS.md
CHANGED
@@ -3,6 +3,61 @@ there might not be any notable changes in new versions of this project.
|
|
3
3
|
|
4
4
|
# NEWS
|
5
5
|
|
6
|
+
## 6.5.0 (June 13, 2025)
|
7
|
+
|
8
|
+
* Add: First-party support for [`file_fixture`](https://api.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture) within factory blocks (Sean Doyle)
|
9
|
+
* Changed: Drop support for Ruby 3.0 (Fernando Perales)
|
10
|
+
* Changed: Add required Ruby version to the gemspec (Christoph Lipautz)
|
11
|
+
* Internal: Add Rails 7.2 to the test matrix (Raj Kumar)
|
12
|
+
* Internal: Add Rails 8.0 to the test matrix (James O'Neill)
|
13
|
+
* Internal: Run `standardrb` on CI runs (Christoph Lipautz)
|
14
|
+
|
15
|
+
|
16
|
+
## 6.4.4 (October 25, 2024)
|
17
|
+
|
18
|
+
* Changed: Bump Factory Bot 6.5.0
|
19
|
+
|
20
|
+
## 6.4.3 (December 29, 2023)
|
21
|
+
|
22
|
+
* Changed: allow sequence definitions for ActiveRecord primary keys (Mike
|
23
|
+
Burns).
|
24
|
+
* Changed: Support Ruby 3.0+, Rails 6.1+ (Mike Burns)
|
25
|
+
* Documentation improvements (obregonia1).
|
26
|
+
* Internal: GitHub Actions improvements (Lorenzo Zabot, ydah).
|
27
|
+
* Internal: RubyGems points to changelog (Tilo Sloboda).
|
28
|
+
* Internal: Bump standard, rake, activerecord, appraisal, rspec-rails (Mike
|
29
|
+
Burns).
|
30
|
+
|
31
|
+
## 6.4.2 (November 23, 2023)
|
32
|
+
* Fixed: Fix Rails 7.1.2 + monkey-patched ActiveRecord compatibility (Adif
|
33
|
+
Sgaid, Benoit Tigeot)
|
34
|
+
* Internal: Test against Rails 7.1 (y-yagi)
|
35
|
+
* Internal: Fix links to old files after renaming the main branch to `main`
|
36
|
+
(y-yagi)
|
37
|
+
|
38
|
+
## 6.4.0 (November 17, 2023)
|
39
|
+
|
40
|
+
* Releasing this for consistency with the factory\_bot dependency.
|
41
|
+
|
42
|
+
## 6.3.0 (November 17, 2023)
|
43
|
+
|
44
|
+
* Changed: reject sequence definitions for ActiveRecord primary keys (Sean
|
45
|
+
Doyle).
|
46
|
+
* Changed: factory\_bot dependency to ~> 6.4 (Mike Burns).
|
47
|
+
* Changed: upgrade dependencies (Daniel Colson).
|
48
|
+
* Add: `projections.json` for Rails.vim (Caleb Hearth).
|
49
|
+
* Docs: fix broken link (Edu Depetris).
|
50
|
+
* Docs: mention Rails generator in docs (Edu Depetris).
|
51
|
+
* Docs: fix typo (Yudai Takada).
|
52
|
+
* Internal: skip Spring version 2.1.1 due to a bug in that release (Christina
|
53
|
+
Entcheva, Daniel Colson).
|
54
|
+
* Internal: test against Rails 6.1 (Antonis Berkakis).
|
55
|
+
* Internal: test against Ruby 3 (Daniel Colson).
|
56
|
+
* Internal: fewer warnings in Cucumber tests (Daniel Colson).
|
57
|
+
* Internal: use GitHub Actions for CI (Mathieu Jobin).
|
58
|
+
* Internal: a whole bunch of cleanup (Daniel Colson).
|
59
|
+
* Internal: fix CI due to a Bundler output change (Mike Burns).
|
60
|
+
|
6
61
|
## 6.2.0 (May 7, 2021)
|
7
62
|
|
8
63
|
* Changed: factory\_bot dependency to ~> 6.2.0
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# factory_bot_rails [![
|
1
|
+
# factory_bot_rails [![Code Climate][grade-image]][grade] [![Gem Version][version-image]][version]
|
2
2
|
|
3
3
|
[factory_bot][fb] is a fixtures replacement with a straightforward definition
|
4
4
|
syntax, support for multiple build strategies (saved instances, unsaved
|
@@ -15,7 +15,7 @@ Check out the [guide](https://github.com/thoughtbot/factory_bot/blob/4-9-0-stabl
|
|
15
15
|
factory\_bot\_rails provides Rails integration for [factory_bot][fb].
|
16
16
|
|
17
17
|
Supported Rails versions are listed in [`Appraisals`](Appraisals). Supported
|
18
|
-
Ruby versions are listed in [`.
|
18
|
+
Ruby versions are listed in [`.github/workflows/build.yml`](.github/workflows/build.yml).
|
19
19
|
|
20
20
|
## Download
|
21
21
|
|
@@ -36,7 +36,7 @@ end
|
|
36
36
|
```
|
37
37
|
|
38
38
|
You may want to configure your test suite to include factory\_bot methods; see
|
39
|
-
[configuration](https://github.com/thoughtbot/factory_bot/blob/
|
39
|
+
[configuration](https://github.com/thoughtbot/factory_bot/blob/main/GETTING_STARTED.md#configure-your-test-suite).
|
40
40
|
|
41
41
|
### Automatic Factory Definition Loading
|
42
42
|
|
@@ -84,6 +84,19 @@ using an empty array:
|
|
84
84
|
config.factory_bot.definition_file_paths = []
|
85
85
|
```
|
86
86
|
|
87
|
+
### File Fixture Support
|
88
|
+
|
89
|
+
Factories have access to [ActiveSupport::Testing::FileFixtures#file_fixture][]
|
90
|
+
helper to read files from tests.
|
91
|
+
|
92
|
+
To disable file fixture support, set `file_fixture_support = false`:
|
93
|
+
|
94
|
+
```rb
|
95
|
+
config.factory_bot.file_fixture_support = false
|
96
|
+
```
|
97
|
+
|
98
|
+
[ActiveSupport::Testing::FileFixtures#file_fixture]: https://api.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture
|
99
|
+
|
87
100
|
### Generators
|
88
101
|
|
89
102
|
Including factory\_bot\_rails in the development group of your Gemfile
|
@@ -144,7 +157,13 @@ Note that factory\_bot\_rails will only use this custom template if you are
|
|
144
157
|
generating each factory in a separate file; it will have no effect if you are
|
145
158
|
generating all of your factories in `test/factories.rb` or `spec/factories.rb`.
|
146
159
|
|
147
|
-
|
160
|
+
Factory\_bot\_rails will add a custom generator:
|
161
|
+
|
162
|
+
```shell
|
163
|
+
rails generate factory_bot:model NAME [field:type field:type] [options]
|
164
|
+
```
|
165
|
+
|
166
|
+
[default factory template]: https://github.com/thoughtbot/factory_bot_rails/tree/main/lib/generators/factory_bot/model/templates/factories.erb
|
148
167
|
|
149
168
|
## Contributing
|
150
169
|
|
@@ -155,24 +174,28 @@ community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
|
|
155
174
|
|
156
175
|
## License
|
157
176
|
|
158
|
-
factory_bot_rails is Copyright © 2008
|
177
|
+
factory_bot_rails is Copyright © 2008 Joe Ferris and thoughtbot. It is free
|
159
178
|
software, and may be redistributed under the terms specified in the
|
160
179
|
[LICENSE](LICENSE) file.
|
161
180
|
|
181
|
+
<!-- START /templates/footer.md -->
|
162
182
|
## About thoughtbot
|
163
183
|
|
164
|
-

|
165
185
|
|
166
|
-
|
186
|
+
This repo is maintained and funded by thoughtbot, inc.
|
167
187
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
168
188
|
|
169
|
-
We
|
189
|
+
We love open source software!
|
170
190
|
See [our other projects][community].
|
171
191
|
We are [available for hire][hire].
|
172
192
|
|
193
|
+
[community]: https://thoughtbot.com/community?utm_source=github
|
194
|
+
[hire]: https://thoughtbot.com/hire-us?utm_source=github
|
195
|
+
|
196
|
+
<!-- END /templates/footer.md -->
|
197
|
+
|
173
198
|
[fb]: https://github.com/thoughtbot/factory_bot
|
174
|
-
[ci]: http://travis-ci.org/thoughtbot/factory_bot_rails?branch=master
|
175
|
-
[ci-image]: https://secure.travis-ci.org/thoughtbot/factory_bot_rails.svg
|
176
199
|
[grade]: https://codeclimate.com/github/thoughtbot/factory_bot_rails
|
177
200
|
[grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot_rails.svg
|
178
201
|
[community]: https://thoughtbot.com/community?utm_source=github
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FactoryBotRails
|
2
|
+
class FactoryValidator
|
3
|
+
def initialize(validators = [])
|
4
|
+
@validators = Array(validators)
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_validator(validator)
|
8
|
+
@validators << validator
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
ActiveSupport::Notifications.subscribe("factory_bot.compile_factory", &validate_compiled_factory)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def validate_compiled_factory
|
18
|
+
proc do |event|
|
19
|
+
@validators.each { |validator| validator.validate!(event.payload) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,12 +3,16 @@
|
|
3
3
|
require "factory_bot"
|
4
4
|
require "factory_bot_rails/generator"
|
5
5
|
require "factory_bot_rails/reloader"
|
6
|
+
require "factory_bot_rails/factory_validator"
|
7
|
+
require "factory_bot_rails/file_fixture_support"
|
6
8
|
require "rails"
|
7
9
|
|
8
10
|
module FactoryBotRails
|
9
11
|
class Railtie < Rails::Railtie
|
10
12
|
config.factory_bot = ActiveSupport::OrderedOptions.new
|
11
13
|
config.factory_bot.definition_file_paths = FactoryBot.definition_file_paths
|
14
|
+
config.factory_bot.validator = FactoryBotRails::FactoryValidator.new
|
15
|
+
config.factory_bot.file_fixture_support = true
|
12
16
|
|
13
17
|
initializer "factory_bot.set_fixture_replacement" do
|
14
18
|
Generator.new(config).run
|
@@ -18,9 +22,26 @@ module FactoryBotRails
|
|
18
22
|
FactoryBot.definition_file_paths = definition_file_paths
|
19
23
|
end
|
20
24
|
|
25
|
+
config.after_initialize do
|
26
|
+
if config.factory_bot.file_fixture_support
|
27
|
+
FactoryBot::SyntaxRunner.include FactoryBotRails::FileFixtureSupport
|
28
|
+
|
29
|
+
ActiveSupport.on_load :active_support_test_case do
|
30
|
+
setup { FactoryBot::SyntaxRunner.file_fixture_support = self }
|
31
|
+
end
|
32
|
+
|
33
|
+
if defined?(RSpec) && RSpec.respond_to?(:configure)
|
34
|
+
RSpec.configure do |config|
|
35
|
+
config.before { FactoryBot::SyntaxRunner.file_fixture_support = self }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
21
41
|
config.after_initialize do |app|
|
22
42
|
FactoryBot.find_definitions
|
23
43
|
Reloader.new(app).run
|
44
|
+
app.config.factory_bot.validator.run
|
24
45
|
end
|
25
46
|
|
26
47
|
private
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"spec/factories/*.rb": {
|
3
|
+
"alternate": "app/models/{singular}.rb",
|
4
|
+
"collection": "model",
|
5
|
+
"command": "factory",
|
6
|
+
"template": [
|
7
|
+
"FactoryBot.define do",
|
8
|
+
" factory :{singular} do",
|
9
|
+
" end",
|
10
|
+
"end"
|
11
|
+
],
|
12
|
+
"test": "spec/models/{singular}_spec.rb"
|
13
|
+
},
|
14
|
+
"test/factories/*.rb": {
|
15
|
+
"alternate": "app/models/{singular}.rb",
|
16
|
+
"collection": "model",
|
17
|
+
"command": "factory",
|
18
|
+
"template": [
|
19
|
+
"FactoryBot.define do",
|
20
|
+
" factory :{singular} do",
|
21
|
+
" end",
|
22
|
+
"end"
|
23
|
+
],
|
24
|
+
"test": "test/models/{singular}_test.rb"
|
25
|
+
}
|
26
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Ferris
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: factory_bot
|
@@ -16,30 +15,86 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
18
|
+
version: '6.5'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
25
|
+
version: '6.5'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: railties
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
32
|
+
version: 6.1.0
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
|
42
|
-
|
39
|
+
version: 6.1.0
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: activerecord
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 6.1.0
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 6.1.0
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: activestorage
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 6.1.0
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 6.1.0
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: mutex_m
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: sqlite3
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
description: factory_bot_rails provides integration between factory_bot and Rails
|
97
|
+
6.1 or newer
|
43
98
|
email: jferris@thoughtbot.com
|
44
99
|
executables: []
|
45
100
|
extensions: []
|
@@ -51,20 +106,24 @@ files:
|
|
51
106
|
- README.md
|
52
107
|
- lib/factory_bot_rails.rb
|
53
108
|
- lib/factory_bot_rails/definition_file_paths.rb
|
109
|
+
- lib/factory_bot_rails/factory_validator.rb
|
110
|
+
- lib/factory_bot_rails/file_fixture_support.rb
|
54
111
|
- lib/factory_bot_rails/generator.rb
|
55
112
|
- lib/factory_bot_rails/generators/non_rspec_generator.rb
|
56
113
|
- lib/factory_bot_rails/generators/null_generator.rb
|
57
114
|
- lib/factory_bot_rails/generators/rspec_generator.rb
|
58
115
|
- lib/factory_bot_rails/railtie.rb
|
59
116
|
- lib/factory_bot_rails/reloader.rb
|
117
|
+
- lib/factory_bot_rails/version.rb
|
60
118
|
- lib/generators/factory_bot.rb
|
61
119
|
- lib/generators/factory_bot/model/model_generator.rb
|
62
120
|
- lib/generators/factory_bot/model/templates/factories.erb
|
121
|
+
- lib/rails/projections.json
|
63
122
|
homepage: https://github.com/thoughtbot/factory_bot_rails
|
64
123
|
licenses:
|
65
124
|
- MIT
|
66
|
-
metadata:
|
67
|
-
|
125
|
+
metadata:
|
126
|
+
changelog_uri: https://github.com/thoughtbot/factory_bot_rails/blob/main/NEWS.md
|
68
127
|
rdoc_options: []
|
69
128
|
require_paths:
|
70
129
|
- lib
|
@@ -72,16 +131,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
131
|
requirements:
|
73
132
|
- - ">="
|
74
133
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
134
|
+
version: 3.0.0
|
76
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
136
|
requirements:
|
78
137
|
- - ">="
|
79
138
|
- !ruby/object:Gem::Version
|
80
139
|
version: '0'
|
81
140
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
-
signing_key:
|
141
|
+
rubygems_version: 3.6.2
|
84
142
|
specification_version: 4
|
85
|
-
summary: factory_bot_rails provides integration between factory_bot and
|
143
|
+
summary: factory_bot_rails provides integration between factory_bot and Rails 6.1
|
86
144
|
or newer
|
87
145
|
test_files: []
|