factory_bot_rails 5.1.1 → 6.2.0

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: 889ea2acf3323850c9bcbaef4585aae23df7d03bf0d0442dc94a4952f5389ed1
4
- data.tar.gz: c2302de95f5a5ce2249115b39d8aa9892fba66a7e9f7eb5e0aec0d4f5673ae58
3
+ metadata.gz: 1b742728304ad03cf96bd0894d77fc2e692bedd7577dab1c7758a0e7cc49fc6e
4
+ data.tar.gz: fa05b3990a3a3d0a819e3afc79bcc7eb218a3b54a4aa071f9e23b3018b349ffd
5
5
  SHA512:
6
- metadata.gz: 1c090ec3a5f2c138091e2d6c85b21ec4efa42a7966df0bb76bd26018522fdaf4ea4a83cb61a02e5f996e42db44698882115d3c84b994908e8234a12b6ca61747
7
- data.tar.gz: d7862a20d0ef8979b46240225702ff6a4356a93b068032901aef4bad395d913ada443613b3e4d0fd5659fcd479e0fe431920cf1d103063d3bc756af19904bcae
6
+ metadata.gz: b99d122d606f1ff76388d3d617d600f78870c4cace484b26ddf69782ee4db752c75b168e2920d00d9b077123fbdabeb82984dbf241aa2fc18555d32f313d9e85
7
+ data.tar.gz: afb2e89740609a4f49765a937f54b8c47f4d569ce8d89f9c6ee2490d76ded24b69b07de95a5924c6afe41a9890d2905d1bc0ce96bd79d1a5a20bb17cd7243adf
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2019 Joe Ferris and thoughtbot, inc.
1
+ Copyright (c) 2008-2020 Joe Ferris and thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/NEWS.md CHANGED
@@ -1,24 +1,49 @@
1
- factory_bot_rails versioning is synced with factory_bot releases. For this reason
1
+ factory\_bot\_rails versioning is synced with factory\_bot releases. For this reason
2
2
  there might not be any notable changes in new versions of this project.
3
3
 
4
4
  # NEWS
5
5
 
6
+ ## 6.2.0 (May 7, 2021)
7
+
8
+ * Changed: factory\_bot dependency to ~> 6.2.0
9
+
10
+ ## 6.1.0 (July 8, 2020)
11
+
12
+ * Changed: factory\_bot dependency to ~> 6.1.0
13
+
14
+ ## 6.0.0 (June 18, 2020)
15
+
16
+ * Fixed: generate a plural factory name when the --force-plural flag is provided
17
+ * Changed: factory\_bot dependency to ~> 6.0.0
18
+ * Removed: `"factory_bot.register_reloader"` initializer, now registering the
19
+ reloader after application initialization
20
+ * Removed: support for EOL versions of Ruby (2.3, 2.4) and Rails (4.2)
21
+
22
+ ## 5.2.0 (April 26, 2020)
23
+
24
+ * Changed: factory\_bot dependency to ~> 5.2.0
25
+
6
26
  ## 5.1.1 (September 24, 2019)
27
+
7
28
  * Fixed: Ensure definitions do not load before I18n is initialized
8
29
 
9
30
  ## 5.1.0 (September 24, 2019)
10
- * Changed: factory_bot dependency to ~> 5.1.0
31
+
32
+ * Changed: factory\_bot dependency to ~> 5.1.0
11
33
 
12
34
  ## 5.0.2 (April 14, 2019)
35
+
13
36
  * Bugfix: Reload factory\_bot whenever the application changes to avoid holding
14
37
  onto stale object references
15
38
  * Bugfix: Avoid watching project root when no factory definitions exist
16
39
 
17
40
  ## 5.0.1 (February 9, 2019)
41
+
18
42
  * Bugfix: Avoid watching files and directories that don't exist (to avoid a
19
43
  file watching bug in Rails https://github.com/rails/rails/issues/32700)
20
44
 
21
45
  ## 5.0.0 (February 1, 2019)
46
+
22
47
  * Added: calling reload! in the Rails console will reload any factory definition files that have changed
23
48
  * Added: support for custom generator templates
24
49
  * Added: `definition_file_paths` configuration option, making it easier to place factories in custom locations
@@ -27,35 +52,45 @@ there might not be any notable changes in new versions of this project.
27
52
  * Removed: support for EOL version of Ruby and Rails
28
53
 
29
54
  ## 4.11.1 (September 7, 2018)
55
+
30
56
  * Update generator to use dynamic attributes instead of deprecated static attributes
31
57
 
32
58
  ## 4.11.0 (August 16, 2018)
59
+
33
60
  * No notable changes
34
61
 
35
62
  ## 4.10.0 (May 25, 2018)
63
+
36
64
  * No notable changes
37
65
 
38
66
  ## 4.8.2 (October 20, 2017)
67
+
39
68
  * Rename factory\_girl\_rails to factory\_bot\_rails
40
69
 
41
70
  ## 4.7.0 (April 1, 2016)
71
+
42
72
  * No notable changes
43
73
 
44
74
  ## 4.6.0 (February 1, 2016)
75
+
45
76
  * No notable changes
46
77
 
47
78
  ## 4.5.0 (October 17, 2014)
79
+
48
80
  * Improved README
49
81
 
50
82
  ## 4.4.1 (February 26, 2014)
83
+
51
84
  * Support Spring
52
85
 
53
86
  ## 4.2.1 (February 8, 2013)
87
+
54
88
  * Fix bug when configuring FG and RSpec fixture directory
55
89
  * Remove debugging
56
90
  * Require factory\_girl\_rails explicitly in generator
57
91
 
58
92
  ## 4.2.0 (January 25, 2013)
93
+
59
94
  * Add appraisal and get test suite working reliably with turn gem
60
95
  * Support MiniTest
61
96
  * Allow a custom directory for factories to be specified
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] [![Reviewed by Hound][hound-image]][hound]
1
+ # factory_bot_rails [![Build Status][ci-image]][ci] [![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
@@ -150,19 +150,18 @@ generating all of your factories in `test/factories.rb` or `spec/factories.rb`.
150
150
 
151
151
  Please see [CONTRIBUTING.md](CONTRIBUTING.md).
152
152
 
153
- factory_bot_rails was originally written by Joe Ferris and is now maintained by Josh
154
- Clayton. Many improvements and bugfixes were contributed by the [open source
153
+ factory_bot_rails was originally written by Joe Ferris and is maintained by thoughtbot. Many improvements and bugfixes were contributed by the [open source
155
154
  community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
156
155
 
157
156
  ## License
158
157
 
159
- factory_bot_rails is Copyright © 2008-2019 Joe Ferris and thoughtbot. It is free
158
+ factory_bot_rails is Copyright © 2008-2020 Joe Ferris and thoughtbot. It is free
160
159
  software, and may be redistributed under the terms specified in the
161
160
  [LICENSE](LICENSE) file.
162
161
 
163
162
  ## About thoughtbot
164
163
 
165
- ![thoughtbot](https://thoughtbot.com/logo.png)
164
+ ![thoughtbot](https://thoughtbot.com/brand_assets/93:44.svg)
166
165
 
167
166
  factory_bot_rails is maintained and funded by thoughtbot, inc.
168
167
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
@@ -9,7 +9,7 @@ module FactoryBotRails
9
9
  @generators.test_framework(
10
10
  test_framework,
11
11
  fixture: false,
12
- fixture_replacement: :factory_bot,
12
+ fixture_replacement: :factory_bot
13
13
  )
14
14
  end
15
15
 
@@ -8,7 +8,7 @@ module FactoryBotRails
8
8
  def run
9
9
  @generators.fixture_replacement(
10
10
  fixture_replacement_setting,
11
- dir: factory_bot_directory,
11
+ dir: factory_bot_directory
12
12
  )
13
13
  end
14
14
 
@@ -18,12 +18,9 @@ module FactoryBotRails
18
18
  FactoryBot.definition_file_paths = definition_file_paths
19
19
  end
20
20
 
21
- initializer "factory_bot.register_reloader" do |app|
22
- Reloader.new(app, config).run
23
- end
24
-
25
- config.after_initialize do
26
- FactoryBot.reload
21
+ config.after_initialize do |app|
22
+ FactoryBot.find_definitions
23
+ Reloader.new(app).run
27
24
  end
28
25
 
29
26
  private
@@ -4,9 +4,8 @@ require "factory_bot_rails/definition_file_paths"
4
4
 
5
5
  module FactoryBotRails
6
6
  class Reloader
7
- def initialize(app, config)
7
+ def initialize(app)
8
8
  @app = app
9
- @config = config
10
9
  @paths = DefinitionFilePaths.new(FactoryBot.definition_file_paths)
11
10
  end
12
11
 
@@ -18,7 +17,7 @@ module FactoryBotRails
18
17
 
19
18
  private
20
19
 
21
- attr_reader :app, :config
20
+ attr_reader :app
22
21
 
23
22
  def build_reloader
24
23
  reloader_class.new(@paths.files, @paths.directories) do
@@ -31,12 +30,8 @@ module FactoryBotRails
31
30
  end
32
31
 
33
32
  def register_reloader(reloader)
34
- closed_over_app = app
35
-
36
- config.to_prepare do
37
- if closed_over_app.initialized?
38
- reloader.execute
39
- end
33
+ app.reloader.to_prepare do
34
+ reloader.execute
40
35
  end
41
36
 
42
37
  app.reloaders << reloader
@@ -8,14 +8,18 @@ module FactoryBot
8
8
  File.dirname(__FILE__),
9
9
  "factory_bot",
10
10
  generator_name,
11
- "templates",
11
+ "templates"
12
12
  )
13
13
 
14
14
  File.expand_path(path)
15
15
  end
16
16
 
17
+ def factory_name
18
+ class_name.gsub("::", "").underscore
19
+ end
20
+
17
21
  def explicit_class_option
18
- return if class_name == singular_table_name.camelize
22
+ return if class_name.underscore == factory_name
19
23
 
20
24
  ", class: '#{class_name}'"
21
25
  end
@@ -8,21 +8,21 @@ module FactoryBot
8
8
  :attributes,
9
9
  type: :array,
10
10
  default: [],
11
- banner: "field:type field:type",
11
+ banner: "field:type field:type"
12
12
  )
13
13
 
14
14
  class_option(
15
15
  :dir,
16
16
  type: :string,
17
17
  default: "test/factories",
18
- desc: "The directory or file root where factories belong",
18
+ desc: "The directory or file root where factories belong"
19
19
  )
20
20
 
21
21
  class_option(
22
22
  :suffix,
23
23
  type: :string,
24
24
  default: nil,
25
- desc: "Suffix to add factory file",
25
+ desc: "Suffix to add factory file"
26
26
  )
27
27
 
28
28
  def create_fixture_file
@@ -43,7 +43,7 @@ module FactoryBot
43
43
  insert_into_file(
44
44
  factories_file,
45
45
  factory_definition,
46
- after: "FactoryBot.define do\n",
46
+ after: "FactoryBot.define do\n"
47
47
  )
48
48
  end
49
49
 
@@ -54,17 +54,17 @@ module FactoryBot
54
54
 
55
55
  def factory_definition
56
56
  <<~RUBY
57
- factory :#{singular_table_name}#{explicit_class_option} do
58
- #{factory_attributes.gsub(/^/, ' ')}
57
+ factory :#{factory_name}#{explicit_class_option} do
58
+ #{factory_attributes.gsub(/^/, " ")}
59
59
  end
60
60
 
61
61
  RUBY
62
62
  end
63
63
 
64
64
  def factory_attributes
65
- attributes.map do |attribute|
65
+ attributes.map { |attribute|
66
66
  "#{attribute.name} { #{attribute.default.inspect} }"
67
- end.join("\n")
67
+ }.join("\n")
68
68
  end
69
69
 
70
70
  def filename
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: 5.1.1
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -16,30 +16,30 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.0
19
+ version: 6.2.0
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: 5.1.0
26
+ version: 6.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.0
33
+ version: 5.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.0
40
+ version: 5.0.0
41
41
  description: factory_bot_rails provides integration between factory_bot and rails
42
- 4.2 or newer
42
+ 5.0 or newer
43
43
  email: jferris@thoughtbot.com
44
44
  executables: []
45
45
  extensions: []
@@ -64,7 +64,7 @@ homepage: https://github.com/thoughtbot/factory_bot_rails
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -79,9 +79,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.0.3
83
- signing_key:
82
+ rubygems_version: 3.1.6
83
+ signing_key:
84
84
  specification_version: 4
85
- summary: factory_bot_rails provides integration between factory_bot and rails 4.2
85
+ summary: factory_bot_rails provides integration between factory_bot and rails 5.0
86
86
  or newer
87
87
  test_files: []