factory_bot 4.11.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/GETTING_STARTED.md +121 -37
  3. data/LICENSE +1 -1
  4. data/NEWS.md +351 -0
  5. data/README.md +18 -22
  6. data/lib/factory_bot/aliases.rb +1 -1
  7. data/lib/factory_bot/attribute/dynamic.rb +1 -0
  8. data/lib/factory_bot/attribute.rb +4 -39
  9. data/lib/factory_bot/attribute_assigner.rb +21 -6
  10. data/lib/factory_bot/attribute_list.rb +2 -1
  11. data/lib/factory_bot/callback.rb +3 -2
  12. data/lib/factory_bot/configuration.rb +16 -20
  13. data/lib/factory_bot/declaration/association.rb +14 -1
  14. data/lib/factory_bot/declaration/dynamic.rb +3 -1
  15. data/lib/factory_bot/declaration/implicit.rb +7 -2
  16. data/lib/factory_bot/declaration.rb +4 -4
  17. data/lib/factory_bot/declaration_list.rb +1 -1
  18. data/lib/factory_bot/decorator/attribute_hash.rb +1 -1
  19. data/lib/factory_bot/decorator/invocation_tracker.rb +1 -1
  20. data/lib/factory_bot/decorator.rb +5 -1
  21. data/lib/factory_bot/definition.rb +10 -7
  22. data/lib/factory_bot/definition_hierarchy.rb +1 -11
  23. data/lib/factory_bot/definition_proxy.rb +59 -62
  24. data/lib/factory_bot/errors.rb +7 -4
  25. data/lib/factory_bot/evaluation.rb +1 -1
  26. data/lib/factory_bot/evaluator.rb +5 -5
  27. data/lib/factory_bot/factory.rb +8 -8
  28. data/lib/factory_bot/factory_runner.rb +3 -3
  29. data/lib/factory_bot/find_definitions.rb +1 -1
  30. data/lib/factory_bot/internal.rb +104 -0
  31. data/lib/factory_bot/linter.rb +36 -19
  32. data/lib/factory_bot/null_factory.rb +4 -1
  33. data/lib/factory_bot/null_object.rb +2 -2
  34. data/lib/factory_bot/registry.rb +15 -6
  35. data/lib/factory_bot/reload.rb +3 -3
  36. data/lib/factory_bot/sequence.rb +0 -1
  37. data/lib/factory_bot/strategy/null.rb +2 -4
  38. data/lib/factory_bot/strategy/stub.rb +32 -31
  39. data/lib/factory_bot/strategy_calculator.rb +1 -1
  40. data/lib/factory_bot/strategy_syntax_method_registrar.rb +13 -2
  41. data/lib/factory_bot/syntax/default.rb +12 -24
  42. data/lib/factory_bot/syntax/methods.rb +32 -9
  43. data/lib/factory_bot/syntax.rb +2 -2
  44. data/lib/factory_bot/trait.rb +6 -3
  45. data/lib/factory_bot/version.rb +1 -1
  46. data/lib/factory_bot.rb +103 -138
  47. metadata +72 -32
  48. data/NEWS +0 -306
  49. data/lib/factory_bot/attribute/static.rb +0 -16
  50. data/lib/factory_bot/declaration/static.rb +0 -26
  51. data/lib/factory_bot/decorator/class_key_hash.rb +0 -28
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.1
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Clayton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-07 00:00:00.000000000 Z
12
+ date: 2020-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,42 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 4.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: 4.2.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.0
34
+ version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 3.0.0
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: appraisal
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 2.1.0
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 2.1.0
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: aruba
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -71,46 +71,74 @@ dependencies:
71
71
  name: cucumber
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
75
89
  - !ruby/object:Gem::Version
76
- version: 1.3.15
90
+ version: '0'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
- - - "~>"
95
+ - - ">="
82
96
  - !ruby/object:Gem::Version
83
- version: 1.3.15
97
+ version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rspec
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
- - - "~>"
102
+ - - ">="
89
103
  - !ruby/object:Gem::Version
90
- version: '3.0'
104
+ version: '0'
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - "~>"
109
+ - - ">="
96
110
  - !ruby/object:Gem::Version
97
- version: '3.0'
111
+ version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: rspec-its
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
- - - "~>"
116
+ - - ">="
103
117
  - !ruby/object:Gem::Version
104
- version: '1.0'
118
+ version: '0'
105
119
  type: :development
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
108
122
  requirements:
109
- - - "~>"
123
+ - - ">="
110
124
  - !ruby/object:Gem::Version
111
- version: '1.0'
125
+ version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
- name: simplecov
127
+ name: rubocop
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-performance
114
142
  requirement: !ruby/object:Gem::Requirement
115
143
  requirements:
116
144
  - - ">="
@@ -124,7 +152,21 @@ dependencies:
124
152
  - !ruby/object:Gem::Version
125
153
  version: '0'
126
154
  - !ruby/object:Gem::Dependency
127
- name: timecop
155
+ name: rubocop-rails
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: simplecov
128
170
  requirement: !ruby/object:Gem::Requirement
129
171
  requirements:
130
172
  - - ">="
@@ -165,7 +207,7 @@ files:
165
207
  - GETTING_STARTED.md
166
208
  - LICENSE
167
209
  - NAME.md
168
- - NEWS
210
+ - NEWS.md
169
211
  - README.md
170
212
  - lib/factory_bot.rb
171
213
  - lib/factory_bot/aliases.rb
@@ -173,7 +215,6 @@ files:
173
215
  - lib/factory_bot/attribute/association.rb
174
216
  - lib/factory_bot/attribute/dynamic.rb
175
217
  - lib/factory_bot/attribute/sequence.rb
176
- - lib/factory_bot/attribute/static.rb
177
218
  - lib/factory_bot/attribute_assigner.rb
178
219
  - lib/factory_bot/attribute_list.rb
179
220
  - lib/factory_bot/callback.rb
@@ -183,11 +224,9 @@ files:
183
224
  - lib/factory_bot/declaration/association.rb
184
225
  - lib/factory_bot/declaration/dynamic.rb
185
226
  - lib/factory_bot/declaration/implicit.rb
186
- - lib/factory_bot/declaration/static.rb
187
227
  - lib/factory_bot/declaration_list.rb
188
228
  - lib/factory_bot/decorator.rb
189
229
  - lib/factory_bot/decorator/attribute_hash.rb
190
- - lib/factory_bot/decorator/class_key_hash.rb
191
230
  - lib/factory_bot/decorator/disallows_duplicates_registry.rb
192
231
  - lib/factory_bot/decorator/invocation_tracker.rb
193
232
  - lib/factory_bot/decorator/new_constructor.rb
@@ -201,6 +240,7 @@ files:
201
240
  - lib/factory_bot/factory.rb
202
241
  - lib/factory_bot/factory_runner.rb
203
242
  - lib/factory_bot/find_definitions.rb
243
+ - lib/factory_bot/internal.rb
204
244
  - lib/factory_bot/linter.rb
205
245
  - lib/factory_bot/null_factory.rb
206
246
  - lib/factory_bot/null_object.rb
@@ -223,7 +263,8 @@ files:
223
263
  homepage: https://github.com/thoughtbot/factory_bot
224
264
  licenses:
225
265
  - MIT
226
- metadata: {}
266
+ metadata:
267
+ changelog_uri: https://github.com/thoughtbot/factory_bot/blob/master/NEWS.md
227
268
  post_install_message:
228
269
  rdoc_options: []
229
270
  require_paths:
@@ -232,15 +273,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
273
  requirements:
233
274
  - - ">="
234
275
  - !ruby/object:Gem::Version
235
- version: 1.9.2
276
+ version: 2.3.0
236
277
  required_rubygems_version: !ruby/object:Gem::Requirement
237
278
  requirements:
238
279
  - - ">="
239
280
  - !ruby/object:Gem::Version
240
281
  version: '0'
241
282
  requirements: []
242
- rubyforge_project:
243
- rubygems_version: 2.7.7
283
+ rubygems_version: 3.0.3
244
284
  signing_key:
245
285
  specification_version: 4
246
286
  summary: factory_bot provides a framework and DSL for defining and using model instance
data/NEWS DELETED
@@ -1,306 +0,0 @@
1
- 4.11.1 (September 7, 2018)
2
- Documentation: Include .yardopts in the gem to fix broken RubyDoc links
3
-
4
- 4.11.0 (August, 15, 2018)
5
- Bugfix: Do not raise error for valid build_stubbed methods: decrement, increment, and toggle
6
- Bugfix: Do not add timestamps with build_stubbed for objects that shouldn't have timestamps
7
- Deprecate static attributes
8
-
9
- 4.10.0 (May 25, 2018)
10
- Allow sequences to be rewound
11
-
12
- 4.9.0 (skipped - FactoryGirl only release)
13
-
14
- 4.8.2 (October 20, 2017)
15
- Rename factory_girl to factory_bot
16
-
17
- 4.8.1 (September 28, 2017)
18
- Explicitly define `#destroyed?` within the `Stub` strategy to return `nil` instead of raising
19
- Update various dependencies
20
- Update internal test suite to use RSpec's mocking/stubbing instead of mocha
21
-
22
- 4.8.0 (December 16, 2016)
23
- Improve documentation
24
- Add `FactoryGirl.generate_list` to be consistent with `build_list`/`create_list` and friends
25
- Add `FactoryGirl.use_parent_strategy` configuration to allow associations to leverage parent build strategy
26
-
27
- 4.7.0 (April 1, 2016)
28
- Improve documentation
29
- Improve instrumentation payload to include traits, overrides, and the factory itself
30
- Allow linting of traits
31
- Deprecate factory lookup by class name in preparation for 5.0
32
- Improve internal performance by using flat_map instead of map and compact
33
- Improve handling of dirty attributes after building a stubbed object
34
- Reduce warnings from redefining methods
35
-
36
- 4.6.0 (skipped)
37
-
38
- 4.5.0 (October 17, 2014)
39
- Improve FactoryGirl.lint by including exception and message in output
40
- Allow selective linting
41
- Use more explicit #public_send when doing attribute assignment
42
- Improve documentation around FactoryGirl.lint and initialize_with
43
- Deprecate #ignore in favor of #transient
44
-
45
- 4.4.0 (February 10, 2014)
46
- Add FactoryGirl.lint
47
- Fix memory leak in duplicate traits
48
- Update documentation
49
-
50
- 4.3.0 (November 3, 2013)
51
- Start testing against Rails 4.0 and Ruby 2.0.0
52
- Stop testing against Rails 3.0 and Ruby 1.9.2
53
- Add *_pair methods to only build two objects
54
- Raise if a method is defined with a FactoryGirl block (factory or trait)
55
- Allow use of Symbol#to_proc in callbacks
56
- Add global callbacks
57
- Improve GETTING_STARTED and README
58
-
59
- 4.2.0 (January 18, 2013)
60
- Improve documentation
61
- Allow *_list syntax methods to accept a block
62
- Update gem dependencies
63
- Allow setting id for objects created with `build_stubbed`
64
- Fix Stub strategy to mimic ActiveRecord regarding `created_at`
65
- Evaluate sequences within the context of an Evaluator
66
- Fix Mocha deprecation warning
67
- Fix some warnings when running RUBYOPT=-w rake
68
- Convert test suite to RSpec's "expect" syntax
69
-
70
- 4.1.0 (September 11, 2012)
71
- Allow multiple callbacks to bind to the same block
72
- Fix documentation surrounding the stub strategy
73
-
74
- 4.0.0 (August 3, 2012)
75
- Remove deprecated cucumber_steps
76
- Remove deprecated alternate syntaxes
77
- Deprecate duplicate_attribute_assignment_from_initialize_with, which is now unused
78
- as attributes assigned within initialize_with are not subsequently assigned
79
-
80
- 3.6.1 (August 2, 2012)
81
- Update README to include info about running with JRuby
82
- Update dependencies on RSpec and tiny versions of Rails in Appraisal
83
- Improve flexibility of using traits with associations and add documentation
84
- Stub update_column to raise to mirror ActiveRecord's change from update_attribute
85
-
86
- 3.6.0 (July 27, 2012)
87
- Code/spec cleanup
88
- Allow factories with traits to be used in associations
89
- Refactor Factory to use DefinitionHierarchy to handle managing callbacks,
90
- custom constructor, and custom to_create
91
- Add memoization to speed up factories providing attribute overrides
92
- Add initial support of JRuby when running in 1.9 mode
93
- Improve docs on what happens when including FactoryGirl::Syntax::Methods
94
-
95
- 3.5.0 (June 22, 2012)
96
- Allow created_at to be set when using build_stubbed
97
- Deprecate FactoryGirl step definitions
98
-
99
- 3.4.2 (June 19, 2012)
100
- Fix bug in traits with callbacks called implicitly in factories whose
101
- callbacks trigger multiple times
102
-
103
- 3.4.1 (June 18, 2012)
104
- Fix traits so they can be nested and referred to from other traits
105
-
106
- 3.4.0 (June 11, 2012)
107
- Sequences support Enumerators
108
- Optionally disable duplicate assignment of attributes in initialize_with
109
- Make hash of public attributes available in initialize_with
110
- Support referring to a factory based on class name
111
-
112
- 3.3.0 (May 13, 2012)
113
- Allow to_create, skip_create, and initialize_with to be defined globally
114
- Allow to_create, skip_create, and initialize_with to be defined within traits
115
- Fix deprecation messages for alternate syntaxes (make, generate, etc.)
116
- Improve library documentation
117
- Deprecate after_build, after_create, before_create, after_stub in favor of new callbacks
118
- Introduce new callback syntax: after(:build) {}, after(:custom) {}, or callback(:different) {}
119
- This allows for declaring any callback, usable with custom strategies
120
- Add attributes_for_list and build_stubbed_list with the StrategySyntaxMethodRegistrar
121
- Allow use of syntax methods (build, create, generate, etc) implicitly in callbacks
122
- Internal refactoring of a handful of components
123
-
124
- 3.2.0 (April 24, 2012)
125
- Use AS::Notifications for pub/sub to track running factories
126
- Call new within initialize_with implicitly on the build class
127
- Skip to_create with skip_create
128
- Allow registration of custom strategies
129
- Deprecate alternate syntaxes
130
- Implicitly call factory_bot's syntax methods from dynamic attributes
131
-
132
- 3.1.0 (April 6, 2012)
133
- Sequences support aliases, which reference the same block
134
- Update documentation
135
- Add before_create callback
136
- Support use of #attribute_names method to determine available attributes for steps
137
- Use ActiveSupport::Deprecation for all deprecations
138
-
139
- 3.0.0 (March 23, 2012)
140
- Deprecate the vintage syntax
141
- Remove Rails 2.x support
142
- Remove Ruby 1.8 support
143
- Remove deprecated features, including default_strategy, factory_name,
144
- :method for defining default strategy, ignore on individual attributes, and
145
- interacting with Factory the way you would FactoryGirl
146
-
147
- 2.6.4 (March 16, 2012)
148
- Do not ignore names of transient attributes
149
- Ensure attributes set on instance are calculated uniquely
150
-
151
- 2.6.3 (March 9, 2012)
152
- Fix issue with traits not being present the first time a factory is accessed
153
- Update available Cucumber step definitions to not require a trailing colon
154
- when building a table of attributes to instantiate records with
155
-
156
- 2.6.2 (March 9, 2012)
157
- Allow factories to use all their ancestors' traits
158
- Ignore bin dir generated by bundler
159
- Namespace ::Factory as top-level to fix vintage syntax issue with
160
- Ruby 1.9.2-p3p18
161
-
162
- 2.6.1 (March 2, 2012)
163
- Use FactoryGirl.reload in specs
164
- Clean up running named factories with a particular strategy with
165
- FactoryGirl::FactoryRunner
166
-
167
- 2.6.0 (February 17, 2012)
168
- Improve documentation of has_many associations in the GETTING_STARTED
169
- document
170
- Deprecate :method in favor of :strategy when overriding an association's
171
- build strategy
172
-
173
- 2.5.2 (February 10, 2012)
174
- Fix step definitions to use associations defined in parent factories
175
- Add inline trait support to (build|create)_list
176
- Update ActiveSupport dependency to >= 2.3.9, which introduced
177
- class_attribute
178
-
179
- 2.5.1 (February 3, 2012)
180
- Fix attribute evaluation when the attribute isn't defined in the factory but
181
- is a private method on Object
182
- Update rubygems on Travis before running tests
183
- Fix spec name
184
- Update GETTING_STARTED with correct usage of build_stubbed
185
- Update README with more info on initialize_with
186
- Honor :parent on factory over block nesting
187
-
188
- 2.5.0 (January 20, 2012)
189
- Revert 'Deprecate build_stubbed and attributes_for'
190
- Implement initialize_with to allow overriding object instantiation
191
- Ensure FG runs against Rails 3.2.0
192
-
193
- 2.4.2 (January 18, 2012)
194
- Fix inline traits' interaction with defaults on the factory
195
-
196
- 2.4.1 (January 17, 2012)
197
- Deprecate build_stubbed and attributes_for
198
- Fix inline traits
199
-
200
- 2.4.0 (January 13, 2012)
201
- Refactor internals of FactoryGirl to use anonymous class on which attributes
202
- get defined
203
- Explicitly require Ruby 1.8.7 or higher in gemspec
204
- Fix documentation
205
- Add Gemnasium status to documentation
206
- Supplying a Class to a factory that overrides to_s no longer results in
207
- getting the wrong Class constructed
208
- Be more agnostic about ORMs when using columns in FactoryGirl step
209
- definitions
210
- Test against Active Record 3.2.0.rc2
211
- Update GETTING_STARTED to use Ruby syntax highlighting
212
-
213
- 2.3.2 (November 26, 2011)
214
- Move logic of where instance.save! is set to Definition
215
- Fix method name from aliases_for? to alias_for?
216
- Refactor internal attribute handling to use an anonymous class instead of
217
- faking Ruby's variable resolution. This allows for more sane usage of
218
- attributes without having to manage sorting priority because attributes
219
- can turn themselves into procs, which are used with define_method on a
220
- class so attributes work correctly all the time.
221
-
222
- 2.3.1 (November 23, 2011)
223
- Remove internally-used associate method from all the FactoryGirl::Proxy subclasses
224
- Move around requiring of files
225
- Consolidate errors into factory_bot.rb
226
- Refactor AttributeList to deal with priority only when iterating over
227
- attributes
228
- Refactor internals of some of the Proxy subclasses
229
- Ensure callbacks on traits are executed in the correct order
230
-
231
- 2.3.0 (November 18, 2011)
232
- Registries are named, resulting in better messages when factories, traits,
233
- or sequences cannot be found
234
- Fix incorrect tests
235
- Internals refactoring introducing FactoryGirl::NullFactory,
236
- FactoryGirl::Definition, and FactoryGirl::DeclarationList
237
- Use ActiveSupport for Hash#except and its delegation capabilities
238
- Fix usage of callbacks when added via implicit traits
239
- Use Bundler tasks and clean up dependencies
240
- Fix failing spec for big letters in factory name passed as symbol
241
- Add ability for traits to be added dynamically when creating an instance via
242
- build, create, build_stubbed, or attributes_for
243
-
244
- 2.2.0 (October 14, 2011)
245
- Clean up RSpec suite to not use 'should'
246
- Use create_list in step definitions
247
- Syntax methods that deal with ORM interaction (attributes_for, build, build_stubbed,
248
- and create) now accept a block that yields the result. This results in a
249
- more convenient way to interact with the result than using Object.tap.
250
- Standardize deprecation warnings
251
- Update transient attribute syntax to use blocks instead of calling ignore on
252
- each attribute declaration
253
- Parents can be defined after children because factories are evaluated when
254
- they're used; this means breaking up factories across multiple files will
255
- behave as expected
256
- Large internal refactoring, including changing access modifiers for a
257
- handful of methods for a more clearly defined API
258
-
259
- 2.1.2 (September 23, 2011)
260
- Bugfix: Vintage syntax fixed after bug introduced in 2.1.1
261
- Introduce dependency on activesupport to remove code from Factory class
262
-
263
- 2.1.1 (September 23, 2011) (yanked)
264
- Bugfix: Parent object callbacks are run before child object callbacks
265
- Declarations: allow overriding/modification of individual traits in child factories
266
- Callbacks refactored to not be attributes
267
- Updating documentation for formatting and clarity (incl. new specificity for cucumber)
268
-
269
- 2.1.0 (September 02, 2011)
270
- Bugfix: created_at now defined for stubbed models
271
- Gemspec updated for use with Rails 3.1
272
- Factories can now be modified post-definition (useful for overriding defaults from gems/plugins)
273
- All factories can now be reloaded with Factory.reload
274
- Add :method => build to factory associations to prevent saving of associated objects
275
- Factories defined in {Rails.root}/factories are now loaded by default
276
- Various documentation updates
277
-
278
- 1.1.4 (November 28, 2008)
279
- Factory.build now uses Factory.create for associations of the built object
280
- Factory definitions are now detected in subdirectories, such as
281
- factories/person_factory.rb (thanks to Josh Nichols)
282
- Factory definitions are now loaded after the environment in a Rails project
283
- (fixes some issues with dependencies being loaded too early) (thanks to
284
- Josh Nichols)
285
- Factory names ending in 's' no longer cause problems (thanks to Alex Sharp
286
- and Josh Owens)
287
-
288
- 1.1.3 (September 12, 2008)
289
- Automatically pull in definitions from factories.rb, test/factories.rb, or
290
- spec/factories.rb
291
- 1.1.2 (July 30, 2008)
292
- Improved error handling for invalid and undefined factories/attributes
293
- Improved handling of strings vs symbols vs classes
294
- Added a prettier syntax for handling associations
295
- Updated documentation and fixed compatibility with Rails 2.1
296
-
297
- 1.1.1 (June 23, 2008)
298
- The attribute "name" no longer requires using #add_attribute
299
-
300
- 1.1.0 (June 03, 2008)
301
- Added support for dependent attributes
302
- Fixed the attributes_for build strategy to not build associations
303
- Added support for sequences
304
-
305
- 1.0.0 (May 31, 2008)
306
- First version
@@ -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