factory_bot_rails 5.0.0 → 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: cb1373ed349326df96513782505d2e7e19171d063633723785fa8b19d004334e
4
- data.tar.gz: 85afaa7e96c4196ac2104b8d7937b55840e53ec18752809b885f23fb3b9d3a7f
3
+ metadata.gz: c41b59df4b5238c0092ff30e2684512f2545e2c81043108c333638c151b46ec1
4
+ data.tar.gz: 2a466525baf96430e60c79b2b9d0dbd963a53170d666577f147a6124a625568d
5
5
  SHA512:
6
- metadata.gz: 7fc069195491977c8a878d8368db76a25cd3085f767fb1275de049a3a4d5acd88d68c5684b8d5c0d935a5d720ddaaf393d4304147ae357c4a0488c16009a9b4a
7
- data.tar.gz: 884ac558b9f118f6883b09241e58d08b42fdb85d6f18c3ade81699caad2769c43e47384da9e43219e1f5956b0a57e91899800d6c4bebc45cf751bb4007f305c9
6
+ metadata.gz: 10f6949faf0b18045da785caeb07e66b18c46269a81e195bb8d1bc32a415b70a59f437be960119b222e218d723dc5dd6358e07ebcdb782494631569d30c866d1
7
+ data.tar.gz: 294558d462c35ec56ba610faa785ad49375bbf6f580a93df287c17f7a767debc2fb1dcd0812aca44d52d6f1cea0c15c92f8e39ea0e062813509fb302100d61cf
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2013 Joe Ferris and thoughtbot, inc.
1
+ Copyright (c) 2008-2019 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 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
@@ -151,7 +156,7 @@ community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
151
156
 
152
157
  ## License
153
158
 
154
- factory_bot_rails is Copyright © 2008-2016 Joe Ferris and thoughtbot. It is free
159
+ factory_bot_rails is Copyright © 2008-2019 Joe Ferris and thoughtbot. It is free
155
160
  software, and may be redistributed under the terms specified in the
156
161
  [LICENSE](LICENSE) file.
157
162
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  module FactoryBotRails
4
4
  class DefinitionFilePaths
5
- attr_reader :files, :directories
6
-
7
5
  def initialize(definition_file_paths)
8
6
  @files = []
9
7
  @directories = {}
@@ -13,5 +11,17 @@ module FactoryBotRails
13
11
  @directories[path.to_s] = [:rb]
14
12
  end
15
13
  end
14
+
15
+ def directories
16
+ @directories.select { |path| Dir.exist?(path) }
17
+ end
18
+
19
+ def files
20
+ @files.select { |file| File.exist?(file) }
21
+ end
22
+
23
+ def any?
24
+ directories.any? || files.any?
25
+ end
16
26
  end
17
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.0
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-01 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,44 +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.0
5
- Added: calling reload! in the Rails console will reload any factory definition files that have changed
6
- Added: support for custom generator templates
7
- Added: definition_file_paths configuration option, making it easier to place factories in custom locations
8
- Changed: namespaced models are now generated inside a directory matching the namespace
9
- Changed: added newline between factories generated into the same file
10
- Removed: support for EOL version of Ruby and Rails
11
-
12
- 4.11.1 (September 7, 2018)
13
- Update generator to use dynamic attributes instead of deprecated static attributes
14
-
15
- 4.11.0 (August 16, 2018)
16
- No notable changes
17
-
18
- 4.10.0 (May 25, 2018)
19
- No notable changes
20
-
21
- 4.8.2 (October 20, 2017)
22
- Rename factory_girl_rails to factory_bot_rails
23
-
24
- 4.7.0 (April 1, 2016)
25
- No notable changes
26
-
27
- 4.6.0 (February 1, 2016)
28
- No notable changes
29
-
30
- 4.5.0 (October 17, 2014)
31
- Improved README
32
-
33
- 4.4.1 (February 26, 2014)
34
- Support Spring
35
-
36
- 4.2.1 (February 8, 2013)
37
- Fix bug when configuring FG and RSpec fixture directory
38
- Remove debugging
39
- Require factory_girl_rails explicitly in generator
40
-
41
- 4.2.0 (January 25, 2013)
42
- Add appraisal and get test suite working reliably with turn gem
43
- Support MiniTest
44
- Allow a custom directory for factories to be specified