factory_bot 4.8.2 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +1 -0
  3. data/GETTING_STARTED.md +226 -129
  4. data/LICENSE +1 -1
  5. data/NAME.md +12 -5
  6. data/NEWS.md +351 -0
  7. data/README.md +35 -27
  8. data/lib/factory_bot/aliases.rb +1 -1
  9. data/lib/factory_bot/attribute/dynamic.rb +1 -0
  10. data/lib/factory_bot/attribute.rb +4 -39
  11. data/lib/factory_bot/attribute_assigner.rb +21 -6
  12. data/lib/factory_bot/attribute_list.rb +2 -1
  13. data/lib/factory_bot/callback.rb +3 -2
  14. data/lib/factory_bot/configuration.rb +16 -20
  15. data/lib/factory_bot/declaration/association.rb +14 -1
  16. data/lib/factory_bot/declaration/dynamic.rb +3 -1
  17. data/lib/factory_bot/declaration/implicit.rb +7 -2
  18. data/lib/factory_bot/declaration.rb +4 -4
  19. data/lib/factory_bot/declaration_list.rb +1 -1
  20. data/lib/factory_bot/decorator/attribute_hash.rb +1 -1
  21. data/lib/factory_bot/decorator/invocation_tracker.rb +1 -1
  22. data/lib/factory_bot/decorator.rb +5 -1
  23. data/lib/factory_bot/definition.rb +10 -7
  24. data/lib/factory_bot/definition_hierarchy.rb +1 -11
  25. data/lib/factory_bot/definition_proxy.rb +65 -41
  26. data/lib/factory_bot/errors.rb +7 -4
  27. data/lib/factory_bot/evaluation.rb +1 -1
  28. data/lib/factory_bot/evaluator.rb +5 -5
  29. data/lib/factory_bot/factory.rb +8 -8
  30. data/lib/factory_bot/factory_runner.rb +3 -3
  31. data/lib/factory_bot/find_definitions.rb +1 -1
  32. data/lib/factory_bot/internal.rb +104 -0
  33. data/lib/factory_bot/linter.rb +36 -19
  34. data/lib/factory_bot/null_factory.rb +4 -1
  35. data/lib/factory_bot/null_object.rb +2 -2
  36. data/lib/factory_bot/registry.rb +15 -6
  37. data/lib/factory_bot/reload.rb +3 -3
  38. data/lib/factory_bot/sequence.rb +9 -1
  39. data/lib/factory_bot/strategy/null.rb +2 -4
  40. data/lib/factory_bot/strategy/stub.rb +32 -36
  41. data/lib/factory_bot/strategy_calculator.rb +1 -1
  42. data/lib/factory_bot/strategy_syntax_method_registrar.rb +13 -2
  43. data/lib/factory_bot/syntax/default.rb +12 -24
  44. data/lib/factory_bot/syntax/methods.rb +32 -9
  45. data/lib/factory_bot/syntax.rb +2 -2
  46. data/lib/factory_bot/trait.rb +6 -3
  47. data/lib/factory_bot/version.rb +1 -1
  48. data/lib/factory_bot.rb +103 -134
  49. metadata +79 -64
  50. data/.autotest +0 -9
  51. data/.gitignore +0 -10
  52. data/.rspec +0 -2
  53. data/.simplecov +0 -4
  54. data/.travis.yml +0 -38
  55. data/Appraisals +0 -19
  56. data/Gemfile +0 -8
  57. data/Gemfile.lock +0 -103
  58. data/NEWS +0 -293
  59. data/Rakefile +0 -36
  60. data/cucumber.yml +0 -1
  61. data/factory_bot.gemspec +0 -36
  62. data/factory_girl.gemspec +0 -40
  63. data/gemfiles/3.2.gemfile +0 -10
  64. data/gemfiles/3.2.gemfile.lock +0 -105
  65. data/gemfiles/4.0.gemfile +0 -10
  66. data/gemfiles/4.0.gemfile.lock +0 -105
  67. data/gemfiles/4.1.gemfile +0 -10
  68. data/gemfiles/4.1.gemfile.lock +0 -104
  69. data/gemfiles/4.2.gemfile +0 -10
  70. data/gemfiles/4.2.gemfile.lock +0 -104
  71. data/gemfiles/5.0.gemfile +0 -10
  72. data/gemfiles/5.0.gemfile.lock +0 -103
  73. data/lib/factory_bot/attribute/static.rb +0 -16
  74. data/lib/factory_bot/declaration/static.rb +0 -26
  75. data/lib/factory_bot/decorator/class_key_hash.rb +0 -28
  76. data/lib/factory_girl.rb +0 -5
@@ -1,105 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- factory_bot (4.8.2)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.0.13)
11
- activesupport (= 4.0.13)
12
- builder (~> 3.1.0)
13
- activerecord (4.0.13)
14
- activemodel (= 4.0.13)
15
- activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.13)
17
- arel (~> 4.0.0)
18
- activerecord-deprecated_finders (1.0.4)
19
- activesupport (4.0.13)
20
- i18n (~> 0.6, >= 0.6.9)
21
- minitest (~> 4.2)
22
- multi_json (~> 1.3)
23
- thread_safe (~> 0.1)
24
- tzinfo (~> 0.3.37)
25
- appraisal (2.1.0)
26
- bundler
27
- rake
28
- thor (>= 0.14.0)
29
- arel (4.0.2)
30
- aruba (0.14.2)
31
- childprocess (~> 0.5.6)
32
- contracts (~> 0.9)
33
- cucumber (>= 1.3.19)
34
- ffi (~> 1.9.10)
35
- rspec-expectations (>= 2.99)
36
- thor (~> 0.19)
37
- builder (3.1.4)
38
- childprocess (0.5.9)
39
- ffi (~> 1.0, >= 1.0.11)
40
- contracts (0.16.0)
41
- cucumber (1.3.20)
42
- builder (>= 2.1.2)
43
- diff-lcs (>= 1.1.3)
44
- gherkin (~> 2.12)
45
- multi_json (>= 1.7.5, < 2.0)
46
- multi_test (>= 0.1.2)
47
- diff-lcs (1.3)
48
- docile (1.1.5)
49
- ffi (1.9.18)
50
- gherkin (2.12.2)
51
- multi_json (~> 1.3)
52
- i18n (0.8.6)
53
- json (2.1.0)
54
- minitest (4.7.5)
55
- multi_json (1.12.2)
56
- multi_test (0.1.2)
57
- rake (12.1.0)
58
- rspec (3.6.0)
59
- rspec-core (~> 3.6.0)
60
- rspec-expectations (~> 3.6.0)
61
- rspec-mocks (~> 3.6.0)
62
- rspec-core (3.6.0)
63
- rspec-support (~> 3.6.0)
64
- rspec-expectations (3.6.0)
65
- diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.6.0)
67
- rspec-its (1.2.0)
68
- rspec-core (>= 3.0.0)
69
- rspec-expectations (>= 3.0.0)
70
- rspec-mocks (3.6.0)
71
- diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.6.0)
73
- rspec-support (3.6.0)
74
- simplecov (0.15.1)
75
- docile (~> 1.1.0)
76
- json (>= 1.8, < 3)
77
- simplecov-html (~> 0.10.0)
78
- simplecov-html (0.10.2)
79
- sqlite3 (1.3.13)
80
- thor (0.20.0)
81
- thread_safe (0.3.6)
82
- timecop (0.9.1)
83
- tzinfo (0.3.53)
84
- yard (0.9.9)
85
-
86
- PLATFORMS
87
- ruby
88
-
89
- DEPENDENCIES
90
- activerecord (~> 4.0.13)
91
- activerecord-jdbcsqlite3-adapter
92
- appraisal (~> 2.1.0)
93
- aruba
94
- cucumber (~> 1.3.15)
95
- factory_bot!
96
- jdbc-sqlite3
97
- rspec (~> 3.0)
98
- rspec-its (~> 1.0)
99
- simplecov
100
- sqlite3 (~> 1.3.10)
101
- timecop
102
- yard
103
-
104
- BUNDLED WITH
105
- 1.15.4
data/gemfiles/4.1.gemfile DELETED
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
- gem "jdbc-sqlite3", :platforms => :jruby
7
- gem "sqlite3", "~> 1.3.10", :platforms => :ruby
8
- gem "activerecord", "~> 4.1.14"
9
-
10
- gemspec :path => "../", :name => "factory_bot"
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- factory_bot (4.8.2)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.1.16)
11
- activesupport (= 4.1.16)
12
- builder (~> 3.1)
13
- activerecord (4.1.16)
14
- activemodel (= 4.1.16)
15
- activesupport (= 4.1.16)
16
- arel (~> 5.0.0)
17
- activesupport (4.1.16)
18
- i18n (~> 0.6, >= 0.6.9)
19
- json (~> 1.7, >= 1.7.7)
20
- minitest (~> 5.1)
21
- thread_safe (~> 0.1)
22
- tzinfo (~> 1.1)
23
- appraisal (2.1.0)
24
- bundler
25
- rake
26
- thor (>= 0.14.0)
27
- arel (5.0.1.20140414130214)
28
- aruba (0.14.2)
29
- childprocess (~> 0.5.6)
30
- contracts (~> 0.9)
31
- cucumber (>= 1.3.19)
32
- ffi (~> 1.9.10)
33
- rspec-expectations (>= 2.99)
34
- thor (~> 0.19)
35
- builder (3.2.3)
36
- childprocess (0.5.9)
37
- ffi (~> 1.0, >= 1.0.11)
38
- contracts (0.16.0)
39
- cucumber (1.3.20)
40
- builder (>= 2.1.2)
41
- diff-lcs (>= 1.1.3)
42
- gherkin (~> 2.12)
43
- multi_json (>= 1.7.5, < 2.0)
44
- multi_test (>= 0.1.2)
45
- diff-lcs (1.3)
46
- docile (1.1.5)
47
- ffi (1.9.18)
48
- gherkin (2.12.2)
49
- multi_json (~> 1.3)
50
- i18n (0.8.6)
51
- json (1.8.6)
52
- minitest (5.10.3)
53
- multi_json (1.12.2)
54
- multi_test (0.1.2)
55
- rake (12.1.0)
56
- rspec (3.6.0)
57
- rspec-core (~> 3.6.0)
58
- rspec-expectations (~> 3.6.0)
59
- rspec-mocks (~> 3.6.0)
60
- rspec-core (3.6.0)
61
- rspec-support (~> 3.6.0)
62
- rspec-expectations (3.6.0)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.6.0)
65
- rspec-its (1.2.0)
66
- rspec-core (>= 3.0.0)
67
- rspec-expectations (>= 3.0.0)
68
- rspec-mocks (3.6.0)
69
- diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.6.0)
71
- rspec-support (3.6.0)
72
- simplecov (0.15.1)
73
- docile (~> 1.1.0)
74
- json (>= 1.8, < 3)
75
- simplecov-html (~> 0.10.0)
76
- simplecov-html (0.10.2)
77
- sqlite3 (1.3.13)
78
- thor (0.20.0)
79
- thread_safe (0.3.6)
80
- timecop (0.9.1)
81
- tzinfo (1.2.3)
82
- thread_safe (~> 0.1)
83
- yard (0.9.9)
84
-
85
- PLATFORMS
86
- ruby
87
-
88
- DEPENDENCIES
89
- activerecord (~> 4.1.14)
90
- activerecord-jdbcsqlite3-adapter
91
- appraisal (~> 2.1.0)
92
- aruba
93
- cucumber (~> 1.3.15)
94
- factory_bot!
95
- jdbc-sqlite3
96
- rspec (~> 3.0)
97
- rspec-its (~> 1.0)
98
- simplecov
99
- sqlite3 (~> 1.3.10)
100
- timecop
101
- yard
102
-
103
- BUNDLED WITH
104
- 1.15.4
data/gemfiles/4.2.gemfile DELETED
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
- gem "jdbc-sqlite3", :platforms => :jruby
7
- gem "sqlite3", "~> 1.3.10", :platforms => :ruby
8
- gem "activerecord", "~> 4.2.5.1"
9
-
10
- gemspec :path => "../", :name => "factory_bot"
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- factory_bot (4.8.2)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.2.5.2)
11
- activesupport (= 4.2.5.2)
12
- builder (~> 3.1)
13
- activerecord (4.2.5.2)
14
- activemodel (= 4.2.5.2)
15
- activesupport (= 4.2.5.2)
16
- arel (~> 6.0)
17
- activesupport (4.2.5.2)
18
- i18n (~> 0.7)
19
- json (~> 1.7, >= 1.7.7)
20
- minitest (~> 5.1)
21
- thread_safe (~> 0.3, >= 0.3.4)
22
- tzinfo (~> 1.1)
23
- appraisal (2.1.0)
24
- bundler
25
- rake
26
- thor (>= 0.14.0)
27
- arel (6.0.4)
28
- aruba (0.14.2)
29
- childprocess (~> 0.5.6)
30
- contracts (~> 0.9)
31
- cucumber (>= 1.3.19)
32
- ffi (~> 1.9.10)
33
- rspec-expectations (>= 2.99)
34
- thor (~> 0.19)
35
- builder (3.2.3)
36
- childprocess (0.5.9)
37
- ffi (~> 1.0, >= 1.0.11)
38
- contracts (0.16.0)
39
- cucumber (1.3.20)
40
- builder (>= 2.1.2)
41
- diff-lcs (>= 1.1.3)
42
- gherkin (~> 2.12)
43
- multi_json (>= 1.7.5, < 2.0)
44
- multi_test (>= 0.1.2)
45
- diff-lcs (1.3)
46
- docile (1.1.5)
47
- ffi (1.9.18)
48
- gherkin (2.12.2)
49
- multi_json (~> 1.3)
50
- i18n (0.8.6)
51
- json (1.8.6)
52
- minitest (5.10.3)
53
- multi_json (1.12.2)
54
- multi_test (0.1.2)
55
- rake (12.1.0)
56
- rspec (3.6.0)
57
- rspec-core (~> 3.6.0)
58
- rspec-expectations (~> 3.6.0)
59
- rspec-mocks (~> 3.6.0)
60
- rspec-core (3.6.0)
61
- rspec-support (~> 3.6.0)
62
- rspec-expectations (3.6.0)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.6.0)
65
- rspec-its (1.2.0)
66
- rspec-core (>= 3.0.0)
67
- rspec-expectations (>= 3.0.0)
68
- rspec-mocks (3.6.0)
69
- diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.6.0)
71
- rspec-support (3.6.0)
72
- simplecov (0.15.1)
73
- docile (~> 1.1.0)
74
- json (>= 1.8, < 3)
75
- simplecov-html (~> 0.10.0)
76
- simplecov-html (0.10.2)
77
- sqlite3 (1.3.13)
78
- thor (0.20.0)
79
- thread_safe (0.3.6)
80
- timecop (0.9.1)
81
- tzinfo (1.2.3)
82
- thread_safe (~> 0.1)
83
- yard (0.9.9)
84
-
85
- PLATFORMS
86
- ruby
87
-
88
- DEPENDENCIES
89
- activerecord (~> 4.2.5.1)
90
- activerecord-jdbcsqlite3-adapter
91
- appraisal (~> 2.1.0)
92
- aruba
93
- cucumber (~> 1.3.15)
94
- factory_bot!
95
- jdbc-sqlite3
96
- rspec (~> 3.0)
97
- rspec-its (~> 1.0)
98
- simplecov
99
- sqlite3 (~> 1.3.10)
100
- timecop
101
- yard
102
-
103
- BUNDLED WITH
104
- 1.15.4
data/gemfiles/5.0.gemfile DELETED
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
- gem "jdbc-sqlite3", :platforms => :jruby
7
- gem "sqlite3", "~> 1.3.10", :platforms => :ruby
8
- gem "activerecord", "~> 5.0.0"
9
-
10
- gemspec :path => "../", :name => "factory_bot"
@@ -1,103 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- factory_bot (4.8.2)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.0.6)
11
- activesupport (= 5.0.6)
12
- activerecord (5.0.6)
13
- activemodel (= 5.0.6)
14
- activesupport (= 5.0.6)
15
- arel (~> 7.0)
16
- activesupport (5.0.6)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (~> 0.7)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- appraisal (2.1.0)
22
- bundler
23
- rake
24
- thor (>= 0.14.0)
25
- arel (7.1.4)
26
- aruba (0.14.2)
27
- childprocess (~> 0.5.6)
28
- contracts (~> 0.9)
29
- cucumber (>= 1.3.19)
30
- ffi (~> 1.9.10)
31
- rspec-expectations (>= 2.99)
32
- thor (~> 0.19)
33
- builder (3.2.3)
34
- childprocess (0.5.9)
35
- ffi (~> 1.0, >= 1.0.11)
36
- concurrent-ruby (1.0.5)
37
- contracts (0.16.0)
38
- cucumber (1.3.20)
39
- builder (>= 2.1.2)
40
- diff-lcs (>= 1.1.3)
41
- gherkin (~> 2.12)
42
- multi_json (>= 1.7.5, < 2.0)
43
- multi_test (>= 0.1.2)
44
- diff-lcs (1.3)
45
- docile (1.1.5)
46
- ffi (1.9.18)
47
- gherkin (2.12.2)
48
- multi_json (~> 1.3)
49
- i18n (0.8.6)
50
- json (2.1.0)
51
- minitest (5.10.3)
52
- multi_json (1.12.2)
53
- multi_test (0.1.2)
54
- rake (12.1.0)
55
- rspec (3.6.0)
56
- rspec-core (~> 3.6.0)
57
- rspec-expectations (~> 3.6.0)
58
- rspec-mocks (~> 3.6.0)
59
- rspec-core (3.6.0)
60
- rspec-support (~> 3.6.0)
61
- rspec-expectations (3.6.0)
62
- diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.6.0)
64
- rspec-its (1.2.0)
65
- rspec-core (>= 3.0.0)
66
- rspec-expectations (>= 3.0.0)
67
- rspec-mocks (3.6.0)
68
- diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.6.0)
70
- rspec-support (3.6.0)
71
- simplecov (0.15.1)
72
- docile (~> 1.1.0)
73
- json (>= 1.8, < 3)
74
- simplecov-html (~> 0.10.0)
75
- simplecov-html (0.10.2)
76
- sqlite3 (1.3.13)
77
- thor (0.20.0)
78
- thread_safe (0.3.6)
79
- timecop (0.9.1)
80
- tzinfo (1.2.3)
81
- thread_safe (~> 0.1)
82
- yard (0.9.9)
83
-
84
- PLATFORMS
85
- ruby
86
-
87
- DEPENDENCIES
88
- activerecord (~> 5.0.0)
89
- activerecord-jdbcsqlite3-adapter
90
- appraisal (~> 2.1.0)
91
- aruba
92
- cucumber (~> 1.3.15)
93
- factory_bot!
94
- jdbc-sqlite3
95
- rspec (~> 3.0)
96
- rspec-its (~> 1.0)
97
- simplecov
98
- sqlite3 (~> 1.3.10)
99
- timecop
100
- yard
101
-
102
- BUNDLED WITH
103
- 1.15.4
@@ -1,16 +0,0 @@
1
- module FactoryBot
2
- class Attribute
3
- # @api private
4
- class Static < Attribute
5
- def initialize(name, value, ignored)
6
- super(name, ignored)
7
- @value = value
8
- end
9
-
10
- def to_proc
11
- value = @value
12
- -> { value }
13
- end
14
- end
15
- end
16
- end
@@ -1,26 +0,0 @@
1
- module FactoryBot
2
- class Declaration
3
- # @api private
4
- class Static < Declaration
5
- def initialize(name, value, ignored = false)
6
- super(name, ignored)
7
- @value = value
8
- end
9
-
10
- def ==(other)
11
- name == other.name &&
12
- value == other.value &&
13
- ignored == other.ignored
14
- end
15
-
16
- protected
17
- attr_reader :value
18
-
19
- private
20
-
21
- def build
22
- [Attribute::Static.new(name, @value, @ignored)]
23
- end
24
- end
25
- end
26
- end
@@ -1,28 +0,0 @@
1
- module FactoryBot
2
- class Decorator
3
- class ClassKeyHash < Decorator
4
- def [](key)
5
- @component[symbolized_key key]
6
- end
7
-
8
- def []=(key, value)
9
- @component[symbolized_key key] = value
10
- end
11
-
12
- def key?(key)
13
- @component.key? symbolized_key(key)
14
- end
15
-
16
- private
17
-
18
- def symbolized_key(key)
19
- if key.respond_to?(:to_sym)
20
- key.to_sym
21
- elsif FactoryBot.allow_class_lookup
22
- ActiveSupport::Deprecation.warn "Looking up factories by class is deprecated and will be removed in 5.0. Use symbols instead and set FactoryBot.allow_class_lookup = false", caller
23
- key.to_s.underscore.to_sym
24
- end
25
- end
26
- end
27
- end
28
- end
data/lib/factory_girl.rb DELETED
@@ -1,5 +0,0 @@
1
- require "factory_bot"
2
-
3
- FactoryGirl = FactoryBot
4
-
5
- warn "The factory_girl gem has been deprecated and has been replaced by factory_bot. Please switch to factory_bot as soon as possible."