factory_bot 6.5.1 → 6.5.5
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.
- checksums.yaml +4 -4
- data/GETTING_STARTED.md +24 -2
- data/NEWS.md +421 -323
- data/README.md +2 -2
- data/lib/factory_bot/attribute_assigner.rb +25 -8
- data/lib/factory_bot/callbacks_observer.rb +19 -1
- data/lib/factory_bot/definition.rb +3 -2
- data/lib/factory_bot/definition_proxy.rb +19 -6
- data/lib/factory_bot/evaluator.rb +9 -3
- data/lib/factory_bot/factory.rb +8 -2
- data/lib/factory_bot/find_definitions.rb +2 -2
- data/lib/factory_bot/internal.rb +33 -0
- data/lib/factory_bot/registry.rb +1 -1
- data/lib/factory_bot/sequence.rb +137 -10
- data/lib/factory_bot/strategy/build.rb +2 -0
- data/lib/factory_bot/strategy/create.rb +2 -0
- data/lib/factory_bot/strategy/stub.rb +4 -2
- data/lib/factory_bot/syntax/methods.rb +59 -12
- data/lib/factory_bot/trait.rb +9 -7
- data/lib/factory_bot/uri_manager.rb +63 -0
- data/lib/factory_bot/version.rb +1 -1
- data/lib/factory_bot.rb +33 -3
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc4ecdfaad4faf3f66a090e8a67f73d399e6df92245cf77907b6483cc168b6d
|
4
|
+
data.tar.gz: f0445ea4b16381a1126775e0b127b3c4afd34ac23e9b0dd19930b84e267f8866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b9e9db68e4fc0a222b6229c75391d23bc5014dfadd2e356bc74f037537749c60ee52f0cf4038bff5e5ba7488e9f4623db13a3b0b8d6f6a91fed1c41b0d5faac
|
7
|
+
data.tar.gz: d8002e39646803600784bb64cd1e611ecc0f056e2538a5496ca63d9804cb847582508b7558531fc5a15442077696de17316a7120abba8c1cbbe93cda71aa99b8
|
data/GETTING_STARTED.md
CHANGED
@@ -219,6 +219,26 @@ It is also possible to explicitly specify the class:
|
|
219
219
|
factory :admin, class: "User"
|
220
220
|
```
|
221
221
|
|
222
|
+
Explicit specification of the class, _with the full namespace_, is necessary when defining factories for classes nested within other modules or classes:
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
# foo/bar.rb
|
226
|
+
module Foo
|
227
|
+
class Bar
|
228
|
+
...
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# factories.rb
|
233
|
+
FactoryBot.define do
|
234
|
+
factory :bar, class: 'Foo::Bar' do
|
235
|
+
...
|
236
|
+
end
|
237
|
+
end
|
238
|
+
```
|
239
|
+
|
240
|
+
If the full namespace is not provided in the `factory` statement, you will receive a `NameError: uninitialized constant Bar` error.
|
241
|
+
|
222
242
|
You can pass a constant as well, if the constant is available (note that this
|
223
243
|
can cause test performance problems in large Rails applications, since
|
224
244
|
referring to the constant will cause it to be eagerly loaded).
|
@@ -255,10 +275,12 @@ Factories can be defined anywhere, but will be automatically loaded after
|
|
255
275
|
calling `FactoryBot.find_definitions` if factories are defined in files at the
|
256
276
|
following locations:
|
257
277
|
|
278
|
+
factories.rb
|
279
|
+
factories/**/*.rb
|
258
280
|
test/factories.rb
|
281
|
+
test/factories/**/*.rb
|
259
282
|
spec/factories.rb
|
260
|
-
|
261
|
-
spec/factories/*.rb
|
283
|
+
spec/factories/**/*.rb
|
262
284
|
|
263
285
|
### Static Attributes
|
264
286
|
|