factory_bot_rails 5.0.1 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/NEWS.md +84 -0
- data/README.md +11 -7
- data/lib/factory_bot_rails/definition_file_paths.rb +4 -0
- data/lib/factory_bot_rails/generators/non_rspec_generator.rb +1 -1
- data/lib/factory_bot_rails/generators/rspec_generator.rb +1 -1
- data/lib/factory_bot_rails/railtie.rb +2 -5
- data/lib/factory_bot_rails/reloader.rb +8 -8
- data/lib/generators/factory_bot.rb +6 -2
- data/lib/generators/factory_bot/model/model_generator.rb +8 -8
- metadata +10 -10
- data/NEWS +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e34b7cb7b552958392d728b282403897262a4b6e1da70975ec8a0b9561581eac
|
4
|
+
data.tar.gz: 326411303d3007a412ab5c4d31f833e9f3340c9fb450046941efef2395bc18e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91506d8cccb153ef1a548723b89a8577ac3bf9e46fffae1901cac8edd8c1084a653908ad61be5ef99d22270206f6f6d31f7d4a17c2962c06cb7f12fee95a8569
|
7
|
+
data.tar.gz: a6a332018316694fe1e07ef2d3ae7339e78b0069283eed329ad0942211fdc89564d2904ea2f56a9d6e24e0365003c1b440e76daf21d4aefcb9af1c7f1d60ef1f
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008-
|
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
ADDED
@@ -0,0 +1,84 @@
|
|
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
|
+
## 6.0.0 (June 18, 2020)
|
7
|
+
|
8
|
+
* Fixed: generate a plural factory name when the --force-plural flag is provided
|
9
|
+
* Changed: factory\_bot dependency to ~> 6.0.0
|
10
|
+
* Removed: `"factory_bot.register_reloader"` initializer, now registering the
|
11
|
+
reloader after application initialization
|
12
|
+
* Removed: support for EOL versions of Ruby (2.3, 2.4) and Rails (4.2)
|
13
|
+
|
14
|
+
## 5.1.1 (September 24, 2019)
|
15
|
+
|
16
|
+
* Fixed: Ensure definitions do not load before I18n is initialized
|
17
|
+
|
18
|
+
## 5.1.0 (September 24, 2019)
|
19
|
+
|
20
|
+
* Changed: factory\_bot dependency to ~> 5.1.0
|
21
|
+
|
22
|
+
## 5.0.2 (April 14, 2019)
|
23
|
+
|
24
|
+
* Bugfix: Reload factory\_bot whenever the application changes to avoid holding
|
25
|
+
onto stale object references
|
26
|
+
* Bugfix: Avoid watching project root when no factory definitions exist
|
27
|
+
|
28
|
+
## 5.0.1 (February 9, 2019)
|
29
|
+
|
30
|
+
* Bugfix: Avoid watching files and directories that don't exist (to avoid a
|
31
|
+
file watching bug in Rails https://github.com/rails/rails/issues/32700)
|
32
|
+
|
33
|
+
## 5.0.0 (February 1, 2019)
|
34
|
+
|
35
|
+
* Added: calling reload! in the Rails console will reload any factory definition files that have changed
|
36
|
+
* Added: support for custom generator templates
|
37
|
+
* Added: `definition_file_paths` configuration option, making it easier to place factories in custom locations
|
38
|
+
* Changed: namespaced models are now generated inside a directory matching the namespace
|
39
|
+
* Changed: added newline between factories generated into the same file
|
40
|
+
* Removed: support for EOL version of Ruby and Rails
|
41
|
+
|
42
|
+
## 4.11.1 (September 7, 2018)
|
43
|
+
|
44
|
+
* Update generator to use dynamic attributes instead of deprecated static attributes
|
45
|
+
|
46
|
+
## 4.11.0 (August 16, 2018)
|
47
|
+
|
48
|
+
* No notable changes
|
49
|
+
|
50
|
+
## 4.10.0 (May 25, 2018)
|
51
|
+
|
52
|
+
* No notable changes
|
53
|
+
|
54
|
+
## 4.8.2 (October 20, 2017)
|
55
|
+
|
56
|
+
* Rename factory\_girl\_rails to factory\_bot\_rails
|
57
|
+
|
58
|
+
## 4.7.0 (April 1, 2016)
|
59
|
+
|
60
|
+
* No notable changes
|
61
|
+
|
62
|
+
## 4.6.0 (February 1, 2016)
|
63
|
+
|
64
|
+
* No notable changes
|
65
|
+
|
66
|
+
## 4.5.0 (October 17, 2014)
|
67
|
+
|
68
|
+
* Improved README
|
69
|
+
|
70
|
+
## 4.4.1 (February 26, 2014)
|
71
|
+
|
72
|
+
* Support Spring
|
73
|
+
|
74
|
+
## 4.2.1 (February 8, 2013)
|
75
|
+
|
76
|
+
* Fix bug when configuring FG and RSpec fixture directory
|
77
|
+
* Remove debugging
|
78
|
+
* Require factory\_girl\_rails explicitly in generator
|
79
|
+
|
80
|
+
## 4.2.0 (January 25, 2013)
|
81
|
+
|
82
|
+
* Add appraisal and get test suite working reliably with turn gem
|
83
|
+
* Support MiniTest
|
84
|
+
* 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.
|
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
|
@@ -145,19 +150,18 @@ generating all of your factories in `test/factories.rb` or `spec/factories.rb`.
|
|
145
150
|
|
146
151
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md).
|
147
152
|
|
148
|
-
factory_bot_rails was originally written by Joe Ferris and is
|
149
|
-
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
|
150
154
|
community](https://github.com/thoughtbot/factory_bot_rails/graphs/contributors).
|
151
155
|
|
152
156
|
## License
|
153
157
|
|
154
|
-
factory_bot_rails is Copyright © 2008-
|
158
|
+
factory_bot_rails is Copyright © 2008-2020 Joe Ferris and thoughtbot. It is free
|
155
159
|
software, and may be redistributed under the terms specified in the
|
156
160
|
[LICENSE](LICENSE) file.
|
157
161
|
|
158
162
|
## About thoughtbot
|
159
163
|
|
160
|
-
![thoughtbot](https://thoughtbot.com/
|
164
|
+
![thoughtbot](https://thoughtbot.com/brand_assets/93:44.svg)
|
161
165
|
|
162
166
|
factory_bot_rails is maintained and funded by thoughtbot, inc.
|
163
167
|
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
@@ -18,12 +18,9 @@ module FactoryBotRails
|
|
18
18
|
FactoryBot.definition_file_paths = definition_file_paths
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
Reloader.new(app, config).run
|
23
|
-
end
|
24
|
-
|
25
|
-
config.after_initialize do
|
21
|
+
config.after_initialize do |app|
|
26
22
|
FactoryBot.find_definitions
|
23
|
+
Reloader.new(app).run
|
27
24
|
end
|
28
25
|
|
29
26
|
private
|
@@ -4,23 +4,23 @@ require "factory_bot_rails/definition_file_paths"
|
|
4
4
|
|
5
5
|
module FactoryBotRails
|
6
6
|
class Reloader
|
7
|
-
def initialize(app
|
7
|
+
def initialize(app)
|
8
8
|
@app = app
|
9
|
-
@
|
9
|
+
@paths = DefinitionFilePaths.new(FactoryBot.definition_file_paths)
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
|
+
return unless @paths.any?
|
14
|
+
|
13
15
|
register_reloader(build_reloader)
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
17
19
|
|
18
|
-
attr_reader :app
|
20
|
+
attr_reader :app
|
19
21
|
|
20
22
|
def build_reloader
|
21
|
-
|
22
|
-
|
23
|
-
reloader_class.new(paths.files, paths.directories) do
|
23
|
+
reloader_class.new(@paths.files, @paths.directories) do
|
24
24
|
FactoryBot.reload
|
25
25
|
end
|
26
26
|
end
|
@@ -30,8 +30,8 @@ module FactoryBotRails
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def register_reloader(reloader)
|
33
|
-
|
34
|
-
reloader.
|
33
|
+
app.reloader.to_prepare do
|
34
|
+
reloader.execute
|
35
35
|
end
|
36
36
|
|
37
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 ==
|
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 :#{
|
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
|
65
|
+
attributes.map { |attribute|
|
66
66
|
"#{attribute.name} { #{attribute.default.inspect} }"
|
67
|
-
|
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:
|
4
|
+
version: 6.0.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:
|
11
|
+
date: 2020-06-19 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:
|
19
|
+
version: 6.0.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:
|
26
|
+
version: 6.0.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:
|
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:
|
40
|
+
version: 5.0.0
|
41
41
|
description: factory_bot_rails provides integration between factory_bot and rails
|
42
|
-
|
42
|
+
5.0 or newer
|
43
43
|
email: jferris@thoughtbot.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
@@ -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,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.
|
82
|
+
rubygems_version: 3.1.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
|
-
summary: factory_bot_rails provides integration between factory_bot and rails
|
85
|
+
summary: factory_bot_rails provides integration between factory_bot and rails 5.0
|
86
86
|
or newer
|
87
87
|
test_files: []
|
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
|