factory_bot_rails 6.2.0 → 6.4.3

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: 70ac3e65ecb946bde74a107d453206896d96a0bdd02d52f6e9d99cc4b11ace65
4
+ data.tar.gz: c5478bf4191651ac02e944af9d118f2243b10fd508073b0911c9b165ad6afd1e
5
5
  SHA512:
6
- metadata.gz: b99d122d606f1ff76388d3d617d600f78870c4cace484b26ddf69782ee4db752c75b168e2920d00d9b077123fbdabeb82984dbf241aa2fc18555d32f313d9e85
7
- data.tar.gz: afb2e89740609a4f49765a937f54b8c47f4d569ce8d89f9c6ee2490d76ded24b69b07de95a5924c6afe41a9890d2905d1bc0ce96bd79d1a5a20bb17cd7243adf
6
+ metadata.gz: 4ff19ee6c07babb79676b2ecea45b5abc8dcc6af75042409a3a4e373e9db91787b0f0506d626700303414fc9b2e50f355c2757e1ec9289fccdcf14b6239f30e8
7
+ data.tar.gz: d1a7e2c0c2966eff606e58addc63fe1dba533934fcb45ff1c7399ce5afd5604f1efab1d755e133bcd54f6b12850c76df88108b74df0da19917864e0c94ad8b92
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,47 @@ there might not be any notable changes in new versions of this project.
3
3
 
4
4
  # NEWS
5
5
 
6
+ ## 6.4.3 (December 29, 2023)
7
+
8
+ * Changed: allow sequence definitions for ActiveRecord primary keys (Mike
9
+ Burns).
10
+ * Changed: Support Ruby 3.0+, Rails 6.1+ (Mike Burns)
11
+ * Documentation improvements (obregonia1).
12
+ * Internal: GitHub Actions improvements (Lorenzo Zabot, ydah).
13
+ * Internal: RubyGems points to changelog (Tilo Sloboda).
14
+ * Internal: Bump standard, rake, activerecord, appraisal, rspec-rails (Mike
15
+ Burns).
16
+
17
+ ## 6.4.2 (November 23, 2023)
18
+ * Fixed: Fix Rails 7.1.2 + monkey-patched ActiveRecord compatibility (Adif
19
+ Sgaid, Benoit Tigeot)
20
+ * Internal: Test against Rails 7.1 (y-yagi)
21
+ * Internal: Fix links to old files after renaming the main branch to `main`
22
+ (y-yagi)
23
+
24
+ ## 6.4.0 (November 17, 2023)
25
+
26
+ * Releasing this for consistency with the factory\_bot dependency.
27
+
28
+ ## 6.3.0 (November 17, 2023)
29
+
30
+ * Changed: reject sequence definitions for ActiveRecord primary keys (Sean
31
+ Doyle).
32
+ * Changed: factory\_bot dependency to ~> 6.4 (Mike Burns).
33
+ * Changed: upgrade dependencies (Daniel Colson).
34
+ * Add: `projections.json` for Rails.vim (Caleb Hearth).
35
+ * Docs: fix broken link (Edu Depetris).
36
+ * Docs: mention Rails generator in docs (Edu Depetris).
37
+ * Docs: fix typo (Yudai Takada).
38
+ * Internal: skip Spring version 2.1.1 due to a bug in that release (Christina
39
+ Entcheva, Daniel Colson).
40
+ * Internal: test against Rails 6.1 (Antonis Berkakis).
41
+ * Internal: test against Ruby 3 (Daniel Colson).
42
+ * Internal: fewer warnings in Cucumber tests (Daniel Colson).
43
+ * Internal: use GitHub Actions for CI (Mathieu Jobin).
44
+ * Internal: a whole bunch of cleanup (Daniel Colson).
45
+ * Internal: fix CI due to a Bundler output change (Mike Burns).
46
+
6
47
  ## 6.2.0 (May 7, 2021)
7
48
 
8
49
  * 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
 
@@ -171,8 +177,6 @@ See [our other projects][community].
171
177
  We are [available for hire][hire].
172
178
 
173
179
  [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
180
  [grade]: https://codeclimate.com/github/thoughtbot/factory_bot_rails
177
181
  [grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot_rails.svg
178
182
  [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.3
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: 2023-12-30 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.4'
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.4'
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.4.10
83
114
  signing_key:
84
115
  specification_version: 4
85
116
  summary: factory_bot_rails provides integration between factory_bot and rails 5.0