factory_bot_rails 6.2.0 → 6.4.4

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: 1b742728304ad03cf96bd0894d77fc2e692bedd7577dab1c7758a0e7cc49fc6e
4
- data.tar.gz: fa05b3990a3a3d0a819e3afc79bcc7eb218a3b54a4aa071f9e23b3018b349ffd
3
+ metadata.gz: 4c891e6c2be284a3021b951364c826af87e0b44a5df42a0bf5e46724551af1c5
4
+ data.tar.gz: b00c271f28ebaca3026ab9c7da3a02ea348ecead85cb15cfa275337c9eb5e84f
5
5
  SHA512:
6
- metadata.gz: b99d122d606f1ff76388d3d617d600f78870c4cace484b26ddf69782ee4db752c75b168e2920d00d9b077123fbdabeb82984dbf241aa2fc18555d32f313d9e85
7
- data.tar.gz: afb2e89740609a4f49765a937f54b8c47f4d569ce8d89f9c6ee2490d76ded24b69b07de95a5924c6afe41a9890d2905d1bc0ce96bd79d1a5a20bb17cd7243adf
6
+ metadata.gz: 3064dcddfc012355940f8ed7ab03e454d8d9fef625004eca93b5d6f3e054ba1acfb8151771b3526dc6b6e7f51517289d69934c48cd4b8e957e71cfcacd76cbaf
7
+ data.tar.gz: e887d43df27d88d2979136201293dc8b601af0cc5f243e278706fbdd370fb317783b65a25a6950b218e010bb65c35182f5eac6b7f98dad1539fc8d8e8079650e
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/master/style
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,51 @@ there might not be any notable changes in new versions of this project.
3
3
 
4
4
  # NEWS
5
5
 
6
+ ## 6.4.4 (October 25, 2024)
7
+
8
+ * Changed: Bump Factory Bot 6.5.0
9
+
10
+ ## 6.4.3 (December 29, 2023)
11
+
12
+ * Changed: allow sequence definitions for ActiveRecord primary keys (Mike
13
+ Burns).
14
+ * Changed: Support Ruby 3.0+, Rails 6.1+ (Mike Burns)
15
+ * Documentation improvements (obregonia1).
16
+ * Internal: GitHub Actions improvements (Lorenzo Zabot, ydah).
17
+ * Internal: RubyGems points to changelog (Tilo Sloboda).
18
+ * Internal: Bump standard, rake, activerecord, appraisal, rspec-rails (Mike
19
+ Burns).
20
+
21
+ ## 6.4.2 (November 23, 2023)
22
+ * Fixed: Fix Rails 7.1.2 + monkey-patched ActiveRecord compatibility (Adif
23
+ Sgaid, Benoit Tigeot)
24
+ * Internal: Test against Rails 7.1 (y-yagi)
25
+ * Internal: Fix links to old files after renaming the main branch to `main`
26
+ (y-yagi)
27
+
28
+ ## 6.4.0 (November 17, 2023)
29
+
30
+ * Releasing this for consistency with the factory\_bot dependency.
31
+
32
+ ## 6.3.0 (November 17, 2023)
33
+
34
+ * Changed: reject sequence definitions for ActiveRecord primary keys (Sean
35
+ Doyle).
36
+ * Changed: factory\_bot dependency to ~> 6.4 (Mike Burns).
37
+ * Changed: upgrade dependencies (Daniel Colson).
38
+ * Add: `projections.json` for Rails.vim (Caleb Hearth).
39
+ * Docs: fix broken link (Edu Depetris).
40
+ * Docs: mention Rails generator in docs (Edu Depetris).
41
+ * Docs: fix typo (Yudai Takada).
42
+ * Internal: skip Spring version 2.1.1 due to a bug in that release (Christina
43
+ Entcheva, Daniel Colson).
44
+ * Internal: test against Rails 6.1 (Antonis Berkakis).
45
+ * Internal: test against Ruby 3 (Daniel Colson).
46
+ * Internal: fewer warnings in Cucumber tests (Daniel Colson).
47
+ * Internal: use GitHub Actions for CI (Mathieu Jobin).
48
+ * Internal: a whole bunch of cleanup (Daniel Colson).
49
+ * Internal: fix CI due to a Bundler output change (Mike Burns).
50
+
6
51
  ## 6.2.0 (May 7, 2021)
7
52
 
8
53
  * Changed: factory\_bot dependency to ~> 6.2.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # factory_bot_rails [![Build Status][ci-image]][ci] [![Code Climate][grade-image]][grade] [![Gem Version][version-image]][version]
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 [`.travis.yml`](.travis.yml).
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/master/GETTING_STARTED.md#configure-your-test-suite).
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
 
@@ -144,7 +144,13 @@ Note that factory\_bot\_rails will only use this custom template if you are
144
144
  generating each factory in a separate file; it will have no effect if you are
145
145
  generating all of your factories in `test/factories.rb` or `spec/factories.rb`.
146
146
 
147
- [default factory template]: https://github.com/thoughtbot/factory_bot_rails/tree/master/lib/generators/factory_bot/model/templates/factories.erb
147
+ Factory\_bot\_rails will add a custom generator:
148
+
149
+ ```shell
150
+ rails generate factory_bot:model NAME [field:type field:type] [options]
151
+ ```
152
+
153
+ [default factory template]: https://github.com/thoughtbot/factory_bot_rails/tree/main/lib/generators/factory_bot/model/templates/factories.erb
148
154
 
149
155
  ## Contributing
150
156
 
@@ -155,24 +161,28 @@ community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
155
161
 
156
162
  ## License
157
163
 
158
- factory_bot_rails is Copyright © 2008-2020 Joe Ferris and thoughtbot. It is free
164
+ factory_bot_rails is Copyright © 2008 Joe Ferris and thoughtbot. It is free
159
165
  software, and may be redistributed under the terms specified in the
160
166
  [LICENSE](LICENSE) file.
161
167
 
168
+ <!-- START /templates/footer.md -->
162
169
  ## About thoughtbot
163
170
 
164
- ![thoughtbot](https://thoughtbot.com/brand_assets/93:44.svg)
171
+ ![thoughtbot](https://thoughtbot.com/thoughtbot-logo-for-readmes.svg)
165
172
 
166
- factory_bot_rails is maintained and funded by thoughtbot, inc.
173
+ This repo is maintained and funded by thoughtbot, inc.
167
174
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
168
175
 
169
- We are passionate about open source software.
176
+ We love open source software!
170
177
  See [our other projects][community].
171
178
  We are [available for hire][hire].
172
179
 
180
+ [community]: https://thoughtbot.com/community?utm_source=github
181
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
182
+
183
+ <!-- END /templates/footer.md -->
184
+
173
185
  [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
186
  [grade]: https://codeclimate.com/github/thoughtbot/factory_bot_rails
177
187
  [grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot_rails.svg
178
188
  [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
@@ -1,7 +1,7 @@
1
1
  module FactoryBotRails
2
2
  module Generators
3
3
  class NullGenerator
4
- def initialize(generators)
4
+ def initialize(*)
5
5
  end
6
6
 
7
7
  def run
@@ -3,12 +3,14 @@
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"
6
7
  require "rails"
7
8
 
8
9
  module FactoryBotRails
9
10
  class Railtie < Rails::Railtie
10
11
  config.factory_bot = ActiveSupport::OrderedOptions.new
11
12
  config.factory_bot.definition_file_paths = FactoryBot.definition_file_paths
13
+ config.factory_bot.validator = FactoryBotRails::FactoryValidator.new
12
14
 
13
15
  initializer "factory_bot.set_fixture_replacement" do
14
16
  Generator.new(config).run
@@ -21,6 +23,7 @@ module FactoryBotRails
21
23
  config.after_initialize do |app|
22
24
  FactoryBot.find_definitions
23
25
  Reloader.new(app).run
26
+ app.config.factory_bot.validator.run
24
27
  end
25
28
 
26
29
  private
@@ -2,7 +2,7 @@ require "rails/generators/named_base"
2
2
 
3
3
  module FactoryBot
4
4
  module Generators
5
- class Base < Rails::Generators::NamedBase #:nodoc:
5
+ class Base < Rails::Generators::NamedBase # :nodoc:
6
6
  def self.source_root
7
7
  path = File.join(
8
8
  File.dirname(__FILE__),
@@ -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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.2.0
19
+ version: '6.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 6.2.0
26
+ version: '6.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activerecord
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 5.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 5.0.0
41
69
  description: factory_bot_rails provides integration between factory_bot and rails
42
70
  5.0 or newer
43
71
  email: jferris@thoughtbot.com
@@ -51,6 +79,7 @@ files:
51
79
  - README.md
52
80
  - lib/factory_bot_rails.rb
53
81
  - lib/factory_bot_rails/definition_file_paths.rb
82
+ - lib/factory_bot_rails/factory_validator.rb
54
83
  - lib/factory_bot_rails/generator.rb
55
84
  - lib/factory_bot_rails/generators/non_rspec_generator.rb
56
85
  - lib/factory_bot_rails/generators/null_generator.rb
@@ -60,10 +89,12 @@ files:
60
89
  - lib/generators/factory_bot.rb
61
90
  - lib/generators/factory_bot/model/model_generator.rb
62
91
  - lib/generators/factory_bot/model/templates/factories.erb
92
+ - lib/rails/projections.json
63
93
  homepage: https://github.com/thoughtbot/factory_bot_rails
64
94
  licenses:
65
95
  - MIT
66
- metadata: {}
96
+ metadata:
97
+ changelog_uri: https://github.com/thoughtbot/factory_bot_rails/blob/main/NEWS.md
67
98
  post_install_message:
68
99
  rdoc_options: []
69
100
  require_paths:
@@ -79,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
110
  - !ruby/object:Gem::Version
80
111
  version: '0'
81
112
  requirements: []
82
- rubygems_version: 3.1.6
113
+ rubygems_version: 3.5.22
83
114
  signing_key:
84
115
  specification_version: 4
85
116
  summary: factory_bot_rails provides integration between factory_bot and rails 5.0