fluent_fixtures 0.6.1 → 0.7.0.pre.20180612160111

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e58777cdbc9ae0d2c57ad7a7a74a328fd7976c80
4
- data.tar.gz: 8cef3ad69ad97b9c336e6c05021558ad0c63c9f6
2
+ SHA256:
3
+ metadata.gz: 3e4679ff0187eb29f8abb0adc3f9b5fc8cb635c0512204e52e6b29b2c8e5c22b
4
+ data.tar.gz: 7909c015b6d80d9997aa291c62923e8afb78e23207dee2c68b5f377ead3e201a
5
5
  SHA512:
6
- metadata.gz: 4fafc83c1b7bd3f26225f44dfef26fd4b928c5456359d47687c80dcaa0f6f8ba5564aad5e4a189982bbc31f15f454feecce1f7c0d9b11e9584c2e3737f0592d9
7
- data.tar.gz: 03bf45cfd2e0f8749eab7f6624e992408bf87cc0c701636814efcfb0d4e025030b453733fc6757d78fc9217fbc2af6dd9969b354d450eb1bb83827104cf8b556
6
+ metadata.gz: 1728e0a96edbbacf2d121903607d29c2ba5bf89effdff549c42fbc651c473eaaacffe028caf55065a69973a4abbae7ddb0a3b87458fe66ee2b72da1f79cd0ec6
7
+ data.tar.gz: 783a9d8e793464912ef399ef34fff7949bb44c02597eb91c4ba05f56dc0072e551a58813b7abacf11111750c3f21ca77a509f8e71e421479185628bc3c698132
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,9 +1,69 @@
1
+ 2018-06-12 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .ruby-version, examples/nodb/lib/acme/fixtures/users.rb,
4
+ lib/fluent_fixtures/dsl.rb, lib/fluent_fixtures/factory.rb,
5
+ spec/fluent_fixtures/dsl_spec.rb,
6
+ spec/fluent_fixtures/factory_spec.rb:
7
+ Add composed decorators
8
+ [5a9635f0e734] [github/master, tip]
9
+
10
+ 2017-10-30 Michael Granger <ged@FaerieMUD.org>
11
+
12
+ * README.md:
13
+ Remove the (now retired) project link
14
+ [145d33914658]
15
+
16
+ * .ruby-version:
17
+ Bump ruby version to 2.4
18
+ [7aba5ecd78b7]
19
+
20
+ * .hgtags:
21
+ Added tag v0.6.1 for changeset 26a51ed462e4
22
+ [91ab791a3775]
23
+
24
+ * .hgsigs:
25
+ Added signature for changeset a7a6e88dd27a
26
+ [26a51ed462e4] [v0.6.1]
27
+
28
+ * History.md, lib/fluent_fixtures.rb:
29
+ Bump the patch version, update history.
30
+ [a7a6e88dd27a]
31
+
32
+ * lib/fluent_fixtures/dsl.rb, spec/fluent_fixtures/dsl_spec.rb:
33
+ Fix a bug with decorator aliasing
34
+ [660937258342]
35
+
36
+ * lib/fluent_fixtures/dsl.rb:
37
+ Style consistency fixes
38
+ [834df1ab36a0]
39
+
40
+ * certs/ged.pem:
41
+ Update my gem-signing cert
42
+ [49ee3a922275]
43
+
1
44
  2017-06-26 Michael Granger <ged@FaerieMUD.org>
2
45
 
46
+ * .hgtags:
47
+ Added tag v0.6.0 for changeset 3a609403c94a
48
+ [3d4cf477828e] [github/@]
49
+
50
+ * .hgsigs:
51
+ Added signature for changeset 3d6408efbde6
52
+ [3a609403c94a] [v0.6.0]
53
+
54
+ * History.md, lib/fluent_fixtures.rb:
55
+ Bump the minor version, update history.
56
+ [3d6408efbde6]
57
+
58
+ * lib/fluent_fixtures/factory.rb,
59
+ spec/fluent_fixtures/factory_spec.rb:
60
+ Add support for mutator blocks to factory generators.
61
+ [068568028a13]
62
+
3
63
  * README.md, lib/fluent_fixtures.rb,
4
64
  lib/fluent_fixtures/collection.rb:
5
65
  Start work on better docs
6
- [9f00baf84bb2] [tip]
66
+ [9f00baf84bb2]
7
67
 
8
68
  2017-05-15 Michael Granger <ged@FaerieMUD.org>
9
69
 
@@ -27,7 +87,7 @@
27
87
  spec/fluent_fixtures/dsl_spec.rb,
28
88
  spec/fluent_fixtures/factory_spec.rb:
29
89
  Add a `presave` option for decorators that need a saved instance.
30
- [d4160c6c04e0] [github/master]
90
+ [d4160c6c04e0]
31
91
 
32
92
  2016-12-13 Michael Granger <ged@FaerieMUD.org>
33
93
 
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # fluent_fixtures
2
2
 
3
3
  home
4
- : http://deveiate.org/projects/FluentFixtures
5
-
6
- code
7
4
  : http://bitbucket.org/ged/fluent_fixtures
8
5
 
9
6
  github
@@ -24,7 +24,7 @@ module FluentFixtures
24
24
 
25
25
 
26
26
  # Package version
27
- VERSION = '0.6.1'
27
+ VERSION = '0.7.0'
28
28
 
29
29
  # Version control revision
30
30
  REVISION = %q$Revision: a7a6e88dd27a $
@@ -67,6 +67,33 @@ module FluentFixtures::DSL
67
67
  end
68
68
 
69
69
 
70
+ ### Declare a decorator that is composed out of other decorators and an optional
71
+ ### +block+. The first +hash+ pair should be the name of the declared decorator
72
+ ### and the names of the decorator/s it is composed of.
73
+ ###
74
+ ### Example:
75
+ ###
76
+ ### decorator :foo { ... }
77
+ ### decorator :bar { ... }
78
+ ### compose( :simple => :foo ) { ... }
79
+ ### compose( :complex => [:foo, :bar] ) { ... }
80
+ ### compose( :complex_with_args => {foo: [1,2], bar: "Something"} ) { ... }
81
+ def compose( **hash, &block )
82
+ name, components = hash.first
83
+
84
+ raise ArgumentError, "expected a name and one or more component decorators" unless name
85
+ unless [Symbol, Array, Hash].include?( components.class )
86
+ raise ArgumentError, "invalid compose values: expected symbol, array, or hash; got %p" %
87
+ [ components.class ]
88
+ end
89
+
90
+ options = hash.reject {|k,_| k == name }.merge( prelude: components )
91
+ block ||= Proc.new {}
92
+
93
+ self.decorator( name, options, &block )
94
+ end
95
+
96
+
70
97
  ### Returns +true+ if there is a decorator with the specified +name+.
71
98
  def decorator?( name )
72
99
  return self.decorators.key?( name.to_sym )
@@ -186,6 +186,8 @@ class FluentFixtures::Factory
186
186
  self.log.debug "Applying decorator %p (%p - %p) to a %p with args: %p" %
187
187
  [ decorator_name, decorator_block, decorator_options, instance.class, args ]
188
188
 
189
+ self.apply_prelude( instance, decorator_options[:prelude] ) if decorator_options[:prelude]
190
+
189
191
  instance = self.try_to_save( instance ) if decorator_options[:presave]
190
192
  instance.instance_exec( *args, &decorator_block )
191
193
 
@@ -206,6 +208,28 @@ class FluentFixtures::Factory
206
208
  end
207
209
 
208
210
 
211
+ ### Apply a decorator +prelude+ to the current instance.
212
+ def apply_prelude( instance, prelude, args=[] )
213
+ case prelude
214
+ when Symbol
215
+ self.log.debug "Applying single prelude decorator: %p" % [ prelude ]
216
+ self.apply_named_decorator( instance, args, prelude )
217
+ when Array
218
+ self.log.debug "Applying multiple prelude decorators: %p" % [ prelude ]
219
+ prelude.each do |sublude|
220
+ self.apply_prelude( instance, sublude, args )
221
+ end
222
+ when Hash
223
+ self.log.debug "Applying one or more prelude decorators with args: %p" % [ prelude ]
224
+ prelude.each do |sublude, args|
225
+ self.apply_prelude( instance, sublude, args )
226
+ end
227
+ else
228
+ raise ArgumentError, "unhandled prelude type %p" % [ prelude.class ]
229
+ end
230
+ end
231
+
232
+
209
233
  ### Look for common transaction mechanisms on the fixtured class, and wrap one of
210
234
  ### them around the +block+ if one exists. If no transaction mechanism can be found,
211
235
  ### just yield to the block.
@@ -14,11 +14,12 @@ describe FluentFixtures::DSL do
14
14
  Class.new do
15
15
  def initialize( params={} )
16
16
  @saved = false
17
+ @friends = []
17
18
  params.each do |name, value|
18
19
  self.send( "#{name}=", value )
19
20
  end
20
21
  end
21
- attr_accessor :name, :login, :email
22
+ attr_accessor :name, :login, :email, :friends
22
23
  def save; @saved = true; end
23
24
  def saved?; @saved; end
24
25
  def bizarroify
@@ -142,5 +143,20 @@ describe FluentFixtures::DSL do
142
143
  end
143
144
 
144
145
 
146
+ it "can declare composed decorators" do
147
+ fixture_module.decorator( :with_first_name ) { self.first_name = 'Mark' }
148
+ fixture_module.decorator( :with_last_name ) { self.last_name = 'Walberg' }
149
+ fixture_module.decorator( :with_friends ) do
150
+ self.friends = [ 'Scott Ross', 'Hector Barros', 'Terry Yancey', 'Anothony Thomas' ]
151
+ end
152
+
153
+ fixture_module.compose( :marky_mark => [:with_first_name, :with_last_name, :with_friends] )
154
+
155
+ expect( fixture_module ).to have_decorator( :marky_mark )
156
+ expect( fixture_module.decorator_options[:marky_mark] ).
157
+ to include( prelude: [:with_first_name, :with_last_name, :with_friends] )
158
+ end
159
+
160
+
145
161
  end
146
162
 
@@ -403,5 +403,54 @@ describe FluentFixtures::Factory do
403
403
 
404
404
  end
405
405
 
406
+
407
+ describe "composed decorators" do
408
+
409
+ it "applies a single-decorator prelude before running" do
410
+ fixture_module.decorator( :with_anonymized_email ) { self.email = 'xxx@xxx.xxx' }
411
+ fixture_module.decorator( :with_anonymized_login ) { self.login = 'xxxxxxx' }
412
+ fixture_module.compose( :anonymized => :with_anonymized_email ) do
413
+ self.name = 'Xxxx Xxxxxxxxx'
414
+ end
415
+
416
+ object = factory.anonymized.instance
417
+
418
+ expect( object.name ).to eq( 'Xxxx Xxxxxxxxx' )
419
+ expect( object.email ).to eq( 'xxx@xxx.xxx' )
420
+ expect( object.login ).to_not eq( 'xxxxxxx' )
421
+ end
422
+
423
+
424
+ it "applies a multi-decorator prelude before running" do
425
+ fixture_module.decorator( :with_anonymized_email ) { self.email = 'xxx@xxx.xxx' }
426
+ fixture_module.decorator( :with_anonymized_login ) { self.login = 'xxxxxxx' }
427
+ fixture_module.compose( :anonymized => [:with_anonymized_email, :with_anonymized_login] ) do
428
+ self.name = 'Xxxx Xxxxxxxxx'
429
+ end
430
+
431
+ object = factory.anonymized.instance
432
+
433
+ expect( object.name ).to eq( 'Xxxx Xxxxxxxxx' )
434
+ expect( object.email ).to eq( 'xxx@xxx.xxx' )
435
+ expect( object.login ).to eq( 'xxxxxxx' )
436
+ end
437
+
438
+
439
+ it "applies a decorator prelude with arguments before running" do
440
+ fixture_module.decorator( :with_anonymized_email ) do |base_email='xxx@xxxx.com'|
441
+ self.email = base_email.gsub(/\w/, 'x')
442
+ end
443
+ fixture_module.compose( :anonymized => {with_anonymized_email: 'thomas.dalton@example.com'} ) do
444
+ self.name = 'Xxxx Xxxxxxxxx'
445
+ end
446
+
447
+ object = factory.anonymized.instance
448
+
449
+ expect( object.name ).to eq( 'Xxxx Xxxxxxxxx' )
450
+ expect( object.email ).to eq( 'xxxxxx.xxxxxx@xxxxxxx.xxx' )
451
+ end
452
+
453
+ end
454
+
406
455
  end
407
456
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent_fixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0.pre.20180612160111
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  X0qdrKi+2aZZ0NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
36
36
  OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
37
37
  -----END CERTIFICATE-----
38
- date: 2017-10-30 00:00:00.000000000 Z
38
+ date: 2018-06-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: loggability
@@ -232,12 +232,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
232
  version: 2.2.0
233
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  requirements:
235
- - - ">="
235
+ - - ">"
236
236
  - !ruby/object:Gem::Version
237
- version: '0'
237
+ version: 1.3.1
238
238
  requirements: []
239
239
  rubyforge_project:
240
- rubygems_version: 2.6.13
240
+ rubygems_version: 2.7.6
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: FluentFixtures is a toolkit for building testing objects with a fluent interface
metadata.gz.sig CHANGED
Binary file