fluent_fixtures 0.7.0 → 0.8.0

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
2
  SHA256:
3
- metadata.gz: 2c4441c7dbd6c2cc1cfdf107f21c8da0c6ce37e1310f0af99621c15cb572ef26
4
- data.tar.gz: 7237695bdb925e6488e217c652db69b2a3d24cbb89cb678f7aaf64f7f8794663
3
+ metadata.gz: 6a7e2e3b328e9867c88b743b0ea894d7da533cd607d3f4818ccef00435807c7e
4
+ data.tar.gz: 228bfcd1d43e45a4b1b4f6181dab3d9afaee9f4badac8f087c26a1a376c6b0e3
5
5
  SHA512:
6
- metadata.gz: 2574f0db599961962af3cbc9cbea2707d5c4049bd7fd0f51ec477b6240ed33a8ac0bcf1fba07b24e4d3756cc9edc0bfd4774a20b374e1b44ba4a471f03caebf2
7
- data.tar.gz: 27783dc76655e384c5e6b11d31d7169f9225d10e5939df0923bb85456be9ea8db70b80c27092d850716221fc8649fdebc47db63fb7a419342809b4963194adc4
6
+ metadata.gz: a8f729d6dab5beea7f7aad23644ff0729762d331cc3a6e9e7df68da45f4c01f935060c2160568fddb680d28eff33cc5f62c15ec074cb7c5dacd8c370cd80f22d
7
+ data.tar.gz: 40b97ecd4abe2bdacc83cab72fe098555e1f726373740d417896a5d395ad9149097af982f5a2127a5620658a71569b6a2a1a3ddcee35bbde1bd7288242214831
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,5 @@
1
- %}�ɾr'Sş�����U����Ddfu���0Q�c^��b�{�nst��@����~�YJ���ij�J+�Pǔ]_�x��|f
1
+ ���BysBJ4M٠Ig��vO~9� �X�{�25[���k�2FJ9���� `S����,PQC�f�2R
2
+ E�3����wp�H����9�ڤ���r��G�,�W.{ZƜ_��$�D�^E�Pƃ
3
+ ���E���ے;?s�wd��$h�4P!Z}�s+��j���,�����:�PM`J�g1=p/���Q.��2�b 3�#��:��J�Y,�S��J�ſ�����|��\Vs�U�
4
+ 3Nʁ�$<��� !�i�O�d��H�Ҏ�~uٗ����\��е��AΓ�F������A��2��n��jw���] ҥ�(�t=��sKe`���318D?�]�-m�Vk��9/���}�
5
+ |�dž�!r��/�*?��ZVL~��qx �c
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v0.8.0 [2018-08-28] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+
5
+ - Add syntax for adding decorators to already-existing fixtures
6
+
7
+
1
8
  ## v0.7.0 [2018-06-12] Michael Granger <ged@FaerieMUD.org>
2
9
 
3
10
  Enhancements:
data/TheSetup.md CHANGED
@@ -164,6 +164,45 @@ The block executes in the context of the new object if the `base` block doesn't
164
164
  ### Hooks
165
165
 
166
166
 
167
+ ### Extending Other Fixtures
168
+
169
+ Sometimes you want a collection of decorators that apply to fixtures declared elsewhere. You can do this to keeps concerns which are separated in the code separate in fixtures which test it, or just to aid in organizing fixtures according to criteria other than their fixtured classes.
170
+
171
+ To do this, you can use the `#additions_for` declaration. It takes the name of the fixture you wish to extend as its first argument, and a block that will be evaluated in the context of the target fixture as the second:
172
+
173
+ # lib/acme/fixtures/customers.rb
174
+ require 'faker'
175
+
176
+ module Acme::Fixtures::Customers
177
+ # ...
178
+ base :customer do
179
+ self.first_name ||= Faker::Name.first_name
180
+ self.last_name ||= Faker::Name.last_name
181
+ end
182
+ end
183
+
184
+
185
+ # lib/acme/fixtures/stripe.rb
186
+ require 'stripe'
187
+
188
+ module Acme::Fixtures::Stripe
189
+
190
+ additions_for( :customers ) do
191
+ decorator :with_stripe_custom_account do
192
+ acct = Stripe::Account.create({
193
+ :country => "US",
194
+ :type => "custom"
195
+ })
196
+ self.stripe_id = acct.id
197
+ end
198
+ end
199
+
200
+ end
201
+
202
+ user = Acme::Fixtures.customer.with_stripe_custom_account.create
203
+ user.stripe_id
204
+ # => "acct_12QkqYGSOD4VcegJ"
205
+
167
206
 
168
207
  ## RSpec
169
208
 
@@ -24,10 +24,10 @@ module FluentFixtures
24
24
 
25
25
 
26
26
  # Package version
27
- VERSION = '0.7.0'
27
+ VERSION = '0.8.0'
28
28
 
29
29
  # Version control revision
30
- REVISION = %q$Revision: fd705f7880a5 $
30
+ REVISION = %q$Revision: 3f30d963e0b9 $
31
31
 
32
32
 
33
33
  # Loggability API -- set up a named logger
@@ -94,6 +94,16 @@ module FluentFixtures::DSL
94
94
  end
95
95
 
96
96
 
97
+ ### Declare decorators for the +other_fixture+ instead of the current one.
98
+ def additions_for( other_fixture, &block )
99
+ self.depends_on( other_fixture )
100
+ mod = self.collection.modules[ other_fixture ] or
101
+ raise "no such fixture %p" % [ other_fixture ]
102
+
103
+ mod.module_eval( &block )
104
+ end
105
+
106
+
97
107
  ### Returns +true+ if there is a decorator with the specified +name+.
98
108
  def decorator?( name )
99
109
  return self.decorators.key?( name.to_sym )
@@ -158,5 +158,25 @@ describe FluentFixtures::DSL do
158
158
  end
159
159
 
160
160
 
161
+ it "can extend an existing fixture with more decorators" do
162
+ expect( collection ).to receive( :load ) do |*args|
163
+ expect( args ).to eq([ :tyrants ])
164
+ collection.modules[ :tyrants ] = fixture_module
165
+ end
166
+
167
+ mod = Module.new do
168
+ def self::name ; "FixtureAdditionTests"; end
169
+ end
170
+
171
+ mod.extend( collection )
172
+ mod.additions_for( :tyrants ) do
173
+ decorator :despotic do
174
+ self.authority = :absolute
175
+ end
176
+ end
177
+
178
+ expect( fixture_module ).to have_decorator( :despotic )
179
+ end
180
+
161
181
  end
162
182
 
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.7.0
4
+ version: 0.8.0
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: 2018-06-12 00:00:00.000000000 Z
38
+ date: 2018-08-29 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: loggability
metadata.gz.sig CHANGED
Binary file