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