faker_maker 1.1.10 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/usage/lifecycle_hooks.md +3 -5
- data/lib/faker_maker/factory.rb +1 -1
- data/lib/faker_maker/lifecycle_hooks.rb +2 -2
- data/lib/faker_maker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '085b4651f6fd8681a1544f7fcc1c3ec05709f2709c701268c16efaf09b4ce06d'
|
4
|
+
data.tar.gz: bdabf0075d7453c39a24554c659e859781c15b1fc7880b5115134e38438fe756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19b799c28b8409657e9f8abe28eaaa6dabf6caefc66055e894c843994a9a8b1f66aedc35a356a0da5e620bd8d12cd25dc5cf077393e4dea80f17b9d1cb048c48
|
7
|
+
data.tar.gz: 3a288478c6afff7c15a3246bc445fcad61a93679fbe345503bcb782d254eb08ea72a825b794699dfb18dad7a1b0522ee5d6a5beb24452b476bd8f365a6449c67
|
@@ -16,7 +16,7 @@ For instance:
|
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
FakerMaker.factory :user do
|
19
|
-
before_build do
|
19
|
+
before_build do |instance, factory|
|
20
20
|
puts 'Building an instance of User'
|
21
21
|
end
|
22
22
|
|
@@ -24,10 +24,8 @@ FakerMaker.factory :user do
|
|
24
24
|
email {'patsy@fabulous.co.uk'}
|
25
25
|
admin {false}
|
26
26
|
|
27
|
-
after_build do
|
28
|
-
puts "Built an instance of User (#{
|
27
|
+
after_build do |instance, factory|
|
28
|
+
puts "Built an instance of User (#{instance.name})"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
```
|
32
|
-
|
33
|
-
Access to the factory object is through the `faker_maker_factory` method. The instance under construction is available through the `faker_maker_factory.instance` method.
|
data/lib/faker_maker/factory.rb
CHANGED
@@ -103,7 +103,7 @@ module FakerMaker
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def find_attribute( name = '' )
|
106
|
-
attributes.filter { |a| [a.name, a.translation].include? name }.first
|
106
|
+
attributes.filter { |a| [a.name, a.translation, @naming_strategy&.name(name)].include? name }.first
|
107
107
|
end
|
108
108
|
|
109
109
|
protected
|
@@ -5,11 +5,11 @@ module FakerMaker
|
|
5
5
|
# Lifecycle hooks which can be called during the building of an instance
|
6
6
|
module DefinitionProxy
|
7
7
|
def before_build(&block)
|
8
|
-
@factory.define_singleton_method(:before_build) {
|
8
|
+
@factory.define_singleton_method(:before_build) { yield(self.instance, self) }
|
9
9
|
end
|
10
10
|
|
11
11
|
def after_build(&block)
|
12
|
-
@factory.define_singleton_method(:after_build) {
|
12
|
+
@factory.define_singleton_method(:after_build) { yield(self.instance, self) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/faker_maker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faker_maker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Brookes-Thomas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|