factory_bot 4.10.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/CONTRIBUTING.md +52 -13
  4. data/GETTING_STARTED.md +613 -182
  5. data/LICENSE +1 -1
  6. data/NEWS.md +358 -0
  7. data/README.md +30 -26
  8. data/lib/factory_bot.rb +71 -140
  9. data/lib/factory_bot/aliases.rb +2 -2
  10. data/lib/factory_bot/attribute.rb +4 -39
  11. data/lib/factory_bot/attribute/association.rb +2 -2
  12. data/lib/factory_bot/attribute/dynamic.rb +2 -1
  13. data/lib/factory_bot/attribute_assigner.rb +24 -10
  14. data/lib/factory_bot/attribute_list.rb +3 -2
  15. data/lib/factory_bot/callback.rb +3 -10
  16. data/lib/factory_bot/configuration.rb +15 -19
  17. data/lib/factory_bot/declaration.rb +5 -5
  18. data/lib/factory_bot/declaration/association.rb +14 -1
  19. data/lib/factory_bot/declaration/dynamic.rb +3 -1
  20. data/lib/factory_bot/declaration/implicit.rb +7 -2
  21. data/lib/factory_bot/declaration_list.rb +3 -3
  22. data/lib/factory_bot/decorator.rb +5 -5
  23. data/lib/factory_bot/decorator/attribute_hash.rb +1 -1
  24. data/lib/factory_bot/decorator/invocation_tracker.rb +1 -1
  25. data/lib/factory_bot/definition.rb +49 -20
  26. data/lib/factory_bot/definition_hierarchy.rb +1 -11
  27. data/lib/factory_bot/definition_proxy.rb +125 -43
  28. data/lib/factory_bot/enum.rb +27 -0
  29. data/lib/factory_bot/errors.rb +7 -4
  30. data/lib/factory_bot/evaluation.rb +1 -1
  31. data/lib/factory_bot/evaluator.rb +9 -11
  32. data/lib/factory_bot/evaluator_class_definer.rb +1 -1
  33. data/lib/factory_bot/factory.rb +12 -12
  34. data/lib/factory_bot/factory_runner.rb +4 -4
  35. data/lib/factory_bot/find_definitions.rb +2 -2
  36. data/lib/factory_bot/internal.rb +91 -0
  37. data/lib/factory_bot/linter.rb +41 -28
  38. data/lib/factory_bot/null_factory.rb +13 -4
  39. data/lib/factory_bot/null_object.rb +2 -6
  40. data/lib/factory_bot/registry.rb +17 -8
  41. data/lib/factory_bot/reload.rb +2 -3
  42. data/lib/factory_bot/sequence.rb +5 -6
  43. data/lib/factory_bot/strategy/stub.rb +37 -37
  44. data/lib/factory_bot/strategy_calculator.rb +1 -1
  45. data/lib/factory_bot/strategy_syntax_method_registrar.rb +13 -2
  46. data/lib/factory_bot/syntax.rb +2 -2
  47. data/lib/factory_bot/syntax/default.rb +12 -24
  48. data/lib/factory_bot/syntax/methods.rb +32 -9
  49. data/lib/factory_bot/trait.rb +7 -4
  50. data/lib/factory_bot/version.rb +1 -1
  51. metadata +50 -65
  52. data/.autotest +0 -9
  53. data/.gitignore +0 -10
  54. data/.rspec +0 -3
  55. data/.simplecov +0 -4
  56. data/.travis.yml +0 -58
  57. data/Appraisals +0 -23
  58. data/Gemfile +0 -8
  59. data/Gemfile.lock +0 -103
  60. data/NEWS +0 -298
  61. data/Rakefile +0 -36
  62. data/cucumber.yml +0 -1
  63. data/factory_bot.gemspec +0 -36
  64. data/factory_girl.gemspec +0 -40
  65. data/gemfiles/3.2.gemfile +0 -10
  66. data/gemfiles/3.2.gemfile.lock +0 -107
  67. data/gemfiles/4.0.gemfile +0 -10
  68. data/gemfiles/4.0.gemfile.lock +0 -107
  69. data/gemfiles/4.1.gemfile +0 -10
  70. data/gemfiles/4.1.gemfile.lock +0 -106
  71. data/gemfiles/4.2.gemfile +0 -10
  72. data/gemfiles/4.2.gemfile.lock +0 -106
  73. data/gemfiles/5.0.gemfile +0 -10
  74. data/gemfiles/5.0.gemfile.lock +0 -104
  75. data/gemfiles/5.1.gemfile +0 -10
  76. data/gemfiles/5.1.gemfile.lock +0 -104
  77. data/lib/factory_bot/attribute/static.rb +0 -16
  78. data/lib/factory_bot/declaration/static.rb +0 -26
  79. data/lib/factory_bot/decorator/class_key_hash.rb +0 -28
  80. data/lib/factory_girl.rb +0 -5
@@ -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.1.0"
9
-
10
- gemspec :name => "factory_bot", :path => "../"
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- factory_bot (4.10.0)
5
- activesupport (>= 3.0.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.1.4)
11
- activesupport (= 5.1.4)
12
- activerecord (5.1.4)
13
- activemodel (= 5.1.4)
14
- activesupport (= 5.1.4)
15
- arel (~> 8.0)
16
- activesupport (5.1.4)
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 (8.0.0)
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.9.1)
50
- concurrent-ruby (~> 1.0)
51
- json (2.1.0)
52
- minitest (5.10.3)
53
- multi_json (1.12.2)
54
- multi_test (0.1.2)
55
- rake (12.3.0)
56
- rspec (3.7.0)
57
- rspec-core (~> 3.7.0)
58
- rspec-expectations (~> 3.7.0)
59
- rspec-mocks (~> 3.7.0)
60
- rspec-core (3.7.0)
61
- rspec-support (~> 3.7.0)
62
- rspec-expectations (3.7.0)
63
- diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.7.0)
65
- rspec-its (1.2.0)
66
- rspec-core (>= 3.0.0)
67
- rspec-expectations (>= 3.0.0)
68
- rspec-mocks (3.7.0)
69
- diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.7.0)
71
- rspec-support (3.7.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.12)
84
-
85
- PLATFORMS
86
- ruby
87
-
88
- DEPENDENCIES
89
- activerecord (~> 5.1.0)
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.16.1
@@ -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
@@ -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."