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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +5 -1
- data/History.md +7 -0
- data/TheSetup.md +39 -0
- data/lib/fluent_fixtures.rb +2 -2
- data/lib/fluent_fixtures/dsl.rb +10 -0
- data/spec/fluent_fixtures/dsl_spec.rb +20 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a7e2e3b328e9867c88b743b0ea894d7da533cd607d3f4818ccef00435807c7e
|
4
|
+
data.tar.gz: 228bfcd1d43e45a4b1b4f6181dab3d9afaee9f4badac8f087c26a1a376c6b0e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
1
|
+
���B�ysB�J�4M٠�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�b3�#��:��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
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
|
|
data/lib/fluent_fixtures.rb
CHANGED
@@ -24,10 +24,10 @@ module FluentFixtures
|
|
24
24
|
|
25
25
|
|
26
26
|
# Package version
|
27
|
-
VERSION = '0.
|
27
|
+
VERSION = '0.8.0'
|
28
28
|
|
29
29
|
# Version control revision
|
30
|
-
REVISION = %q$Revision:
|
30
|
+
REVISION = %q$Revision: 3f30d963e0b9 $
|
31
31
|
|
32
32
|
|
33
33
|
# Loggability API -- set up a named logger
|
data/lib/fluent_fixtures/dsl.rb
CHANGED
@@ -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.
|
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-
|
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
|