factory_bot_rails 5.0.1 → 5.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: 396a0440b96b5f0ca9443ff3c8421b4408b5aaf7f4d79de72d41bbaaf53b17d2
4
- data.tar.gz: de1954538587c2c92359c12de3f2b0dbbfb2efcd29f9794500a6068d2d6309ab
3
+ metadata.gz: c41b59df4b5238c0092ff30e2684512f2545e2c81043108c333638c151b46ec1
4
+ data.tar.gz: 2a466525baf96430e60c79b2b9d0dbd963a53170d666577f147a6124a625568d
5
5
  SHA512:
6
- metadata.gz: f10916fc311d14c83d3856f8b00ba6cf884b8ea1609f76327af1c250793cad569a58b6ed245473aeeb20f400a1819dc9c4733cd5a2253c5d7ec8ffc65d574413
7
- data.tar.gz: 97b507d7053d5efc534e5fc2c8b2a95570f71a699f1b943d36ded6dc3c6b2e901b396cdcebc8ecef34c95ad37e2991d365c7c54baa50957a95bcb90ea3810b26
6
+ metadata.gz: 10f6949faf0b18045da785caeb07e66b18c46269a81e195bb8d1bc32a415b70a59f437be960119b222e218d723dc5dd6358e07ebcdb782494631569d30c866d1
7
+ data.tar.gz: 294558d462c35ec56ba610faa785ad49375bbf6f580a93df287c17f7a767debc2fb1dcd0812aca44d52d6f1cea0c15c92f8e39ea0e062813509fb302100d61cf
data/NEWS.md ADDED
@@ -0,0 +1,64 @@
1
+ factory_bot_rails versioning is synced with factory_bot releases. For this reason
2
+ there might not be any notable changes in new versions of this project.
3
+
4
+ # NEWS
5
+
6
+ ## 5.2.0 (April 26, 2020)
7
+ * Changed: factory_bot dependency to ~> 5.2.0
8
+
9
+ ## 5.1.1 (September 24, 2019)
10
+ * Fixed: Ensure definitions do not load before I18n is initialized
11
+
12
+ ## 5.1.0 (September 24, 2019)
13
+ * Changed: factory_bot dependency to ~> 5.1.0
14
+
15
+ ## 5.0.2 (April 14, 2019)
16
+ * Bugfix: Reload factory\_bot whenever the application changes to avoid holding
17
+ onto stale object references
18
+ * Bugfix: Avoid watching project root when no factory definitions exist
19
+
20
+ ## 5.0.1 (February 9, 2019)
21
+ * Bugfix: Avoid watching files and directories that don't exist (to avoid a
22
+ file watching bug in Rails https://github.com/rails/rails/issues/32700)
23
+
24
+ ## 5.0.0 (February 1, 2019)
25
+ * Added: calling reload! in the Rails console will reload any factory definition files that have changed
26
+ * Added: support for custom generator templates
27
+ * Added: `definition_file_paths` configuration option, making it easier to place factories in custom locations
28
+ * Changed: namespaced models are now generated inside a directory matching the namespace
29
+ * Changed: added newline between factories generated into the same file
30
+ * Removed: support for EOL version of Ruby and Rails
31
+
32
+ ## 4.11.1 (September 7, 2018)
33
+ * Update generator to use dynamic attributes instead of deprecated static attributes
34
+
35
+ ## 4.11.0 (August 16, 2018)
36
+ * No notable changes
37
+
38
+ ## 4.10.0 (May 25, 2018)
39
+ * No notable changes
40
+
41
+ ## 4.8.2 (October 20, 2017)
42
+ * Rename factory\_girl\_rails to factory\_bot\_rails
43
+
44
+ ## 4.7.0 (April 1, 2016)
45
+ * No notable changes
46
+
47
+ ## 4.6.0 (February 1, 2016)
48
+ * No notable changes
49
+
50
+ ## 4.5.0 (October 17, 2014)
51
+ * Improved README
52
+
53
+ ## 4.4.1 (February 26, 2014)
54
+ * Support Spring
55
+
56
+ ## 4.2.1 (February 8, 2013)
57
+ * Fix bug when configuring FG and RSpec fixture directory
58
+ * Remove debugging
59
+ * Require factory\_girl\_rails explicitly in generator
60
+
61
+ ## 4.2.0 (January 25, 2013)
62
+ * Add appraisal and get test suite working reliably with turn gem
63
+ * Support MiniTest
64
+ * Allow a custom directory for factories to be specified
data/README.md CHANGED
@@ -66,9 +66,14 @@ This will cause factory\_bot\_rails to automatically load factories in
66
66
  It is possible to use this setting to share factories from a gem:
67
67
 
68
68
  ```rb
69
+ begin
70
+ require 'factory_bot_rails'
71
+ rescue LoadError
72
+ end
73
+
69
74
  class MyEngine < ::Rails::Engine
70
- config.factory_bot.definition_file_paths =
71
- File.expand_path('../factories', __FILE__) if defined?(FactoryBotRails)
75
+ config.factory_bot.definition_file_paths +=
76
+ [File.expand_path('../factories', __FILE__)] if defined?(FactoryBotRails)
72
77
  end
73
78
  ```
74
79
 
@@ -109,7 +114,7 @@ end
109
114
  ```
110
115
 
111
116
  Note that factory\_bot\_rails will not automatically load files in custom
112
- locations unless you add them to `config.factory_bot.defintion_file_paths` as
117
+ locations unless you add them to `config.factory_bot.definition_file_paths` as
113
118
  well.
114
119
 
115
120
  The suffix option allows you to customize the name of the generated file with a
@@ -19,5 +19,9 @@ module FactoryBotRails
19
19
  def files
20
20
  @files.select { |file| File.exist?(file) }
21
21
  end
22
+
23
+ def any?
24
+ directories.any? || files.any?
25
+ end
22
26
  end
23
27
  end
@@ -23,7 +23,7 @@ module FactoryBotRails
23
23
  end
24
24
 
25
25
  config.after_initialize do
26
- FactoryBot.find_definitions
26
+ FactoryBot.reload
27
27
  end
28
28
 
29
29
  private
@@ -7,9 +7,12 @@ module FactoryBotRails
7
7
  def initialize(app, config)
8
8
  @app = app
9
9
  @config = config
10
+ @paths = DefinitionFilePaths.new(FactoryBot.definition_file_paths)
10
11
  end
11
12
 
12
13
  def run
14
+ return unless @paths.any?
15
+
13
16
  register_reloader(build_reloader)
14
17
  end
15
18
 
@@ -18,9 +21,7 @@ module FactoryBotRails
18
21
  attr_reader :app, :config
19
22
 
20
23
  def build_reloader
21
- paths = DefinitionFilePaths.new(FactoryBot.definition_file_paths)
22
-
23
- reloader_class.new(paths.files, paths.directories) do
24
+ reloader_class.new(@paths.files, @paths.directories) do
24
25
  FactoryBot.reload
25
26
  end
26
27
  end
@@ -30,8 +31,12 @@ module FactoryBotRails
30
31
  end
31
32
 
32
33
  def register_reloader(reloader)
34
+ closed_over_app = app
35
+
33
36
  config.to_prepare do
34
- reloader.execute_if_updated
37
+ if closed_over_app.initialized?
38
+ reloader.execute
39
+ end
35
40
  end
36
41
 
37
42
  app.reloaders << reloader
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.0.1
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2020-04-26 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: 5.0.0
19
+ version: 5.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.0.0
26
+ version: 5.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -47,7 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - CONTRIBUTING.md
49
49
  - LICENSE
50
- - NEWS
50
+ - NEWS.md
51
51
  - README.md
52
52
  - lib/factory_bot_rails.rb
53
53
  - lib/factory_bot_rails/definition_file_paths.rb
@@ -79,7 +79,7 @@ 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.1
82
+ rubygems_version: 3.0.3
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: factory_bot_rails provides integration between factory_bot and rails 4.2
data/NEWS DELETED
@@ -1,48 +0,0 @@
1
- factory_bot_rails versioning is synced with factory_bot releases. For this reason
2
- there might not be any notable changes in new versions of this project.
3
-
4
- 5.0.1
5
- Bugfix: Avoid watching files and directories that don't exist (to avoid a
6
- file watching bug in Rails https://github.com/rails/rails/issues/32700)
7
-
8
- 5.0.0
9
- Added: calling reload! in the Rails console will reload any factory definition files that have changed
10
- Added: support for custom generator templates
11
- Added: definition_file_paths configuration option, making it easier to place factories in custom locations
12
- Changed: namespaced models are now generated inside a directory matching the namespace
13
- Changed: added newline between factories generated into the same file
14
- Removed: support for EOL version of Ruby and Rails
15
-
16
- 4.11.1 (September 7, 2018)
17
- Update generator to use dynamic attributes instead of deprecated static attributes
18
-
19
- 4.11.0 (August 16, 2018)
20
- No notable changes
21
-
22
- 4.10.0 (May 25, 2018)
23
- No notable changes
24
-
25
- 4.8.2 (October 20, 2017)
26
- Rename factory_girl_rails to factory_bot_rails
27
-
28
- 4.7.0 (April 1, 2016)
29
- No notable changes
30
-
31
- 4.6.0 (February 1, 2016)
32
- No notable changes
33
-
34
- 4.5.0 (October 17, 2014)
35
- Improved README
36
-
37
- 4.4.1 (February 26, 2014)
38
- Support Spring
39
-
40
- 4.2.1 (February 8, 2013)
41
- Fix bug when configuring FG and RSpec fixture directory
42
- Remove debugging
43
- Require factory_girl_rails explicitly in generator
44
-
45
- 4.2.0 (January 25, 2013)
46
- Add appraisal and get test suite working reliably with turn gem
47
- Support MiniTest
48
- Allow a custom directory for factories to be specified