fluent_fixtures 0.5.0 → 0.6.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
- SHA1:
3
- metadata.gz: 07f6689a16026531fbafd50aac6b959bbeca39b6
4
- data.tar.gz: 3a5b862efb2397f83a02ddc039f2cd4bf1dd5d78
2
+ SHA256:
3
+ metadata.gz: 9362a90cd4e65b2c35636321a6e11f45192c027237df3dd725a8943b822a6919
4
+ data.tar.gz: c7120ddce3a119586469c0cc6406559f11e6ebb48e621522c89a1706de5370b3
5
5
  SHA512:
6
- metadata.gz: f72b30550bb8a415ae07b31f35716bad26989f9f4b3282431beb934dace6f70d907a50e5cd5314715438f161dced90184bfd4fa77e6f505069b07a8e37413302
7
- data.tar.gz: e56f947ee9cca817753af3e260221556db7c9b26fa1bc1eeddeb460f3b5fe3acda0d841c0fd40fefd29ba501fe6f3f346ada32c3b9c041f404819af56f827231
6
+ metadata.gz: 69f588557bea0c2721916b24024d36dcf906e434963b517e2ba345fd439fc8bf883e57f22a1fef5b2f85503bbf4a24129de127393c5b5e41c38c60ad6450052f
7
+ data.tar.gz: 16e8f3ef9a17c3adf522836c8b9776bd86ce6c282d66ff506f3a34b3e0f83b9fd89abd4a39e84a369eb01cd4a0ce23b0d96bb317201b43f44b8a3a23c4da9bf3
checksums.yaml.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,15 @@
1
+ 2017-06-26 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * README.md, lib/fluent_fixtures.rb,
4
+ lib/fluent_fixtures/collection.rb:
5
+ Start work on better docs
6
+ [9f00baf84bb2] [tip]
7
+
1
8
  2017-05-15 Michael Granger <ged@FaerieMUD.org>
2
9
 
3
10
  * .hgtags:
4
11
  Added tag v0.5.0 for changeset a6a7c1070f6d
5
- [b8576e389b5e] [tip]
12
+ [b8576e389b5e]
6
13
 
7
14
  * .hgsigs:
8
15
  Added signature for changeset ed67198925b5
@@ -20,7 +27,7 @@
20
27
  spec/fluent_fixtures/dsl_spec.rb,
21
28
  spec/fluent_fixtures/factory_spec.rb:
22
29
  Add a `presave` option for decorators that need a saved instance.
23
- [d4160c6c04e0]
30
+ [d4160c6c04e0] [github/master]
24
31
 
25
32
  2016-12-13 Michael Granger <ged@FaerieMUD.org>
26
33
 
@@ -49,7 +56,7 @@
49
56
 
50
57
  * .hgtags:
51
58
  Added tag v0.3.0 for changeset e544333544cd
52
- [85277035e13e] [github/master]
59
+ [85277035e13e]
53
60
 
54
61
  * .hgsigs:
55
62
  Added signature for changeset 5b362f519048
data/History.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## v0.6.0 [2017-06-26] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+
5
+ - Add support for mutator blocks to factory generators.
6
+
7
+ Documentation:
8
+
9
+ - Added the beginnings of API docs.
10
+
11
+
1
12
  ## v0.5.0 [2017-05-12] Michael Granger <ged@FaerieMUD.org>
2
13
 
3
14
  Enhancements:
data/README.md CHANGED
@@ -36,8 +36,8 @@ If you're already on your way and just want some API docs, [we got those, too](F
36
36
  ## Contributing
37
37
 
38
38
  You can check out the current development source with Mercurial via its
39
- {project page}[http://bitbucket.org/ged/fluent_fixtures]. Or if you prefer Git, via
40
- {its Github mirror}[https://github.com/ged/fluent_fixtures].
39
+ [project page][bitbucket]. Or if you prefer Git, via [its Github
40
+ mirror][github].
41
41
 
42
42
  After checking out the source, run:
43
43
 
@@ -78,3 +78,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
78
78
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79
79
 
80
80
 
81
+ [bitbucket]: http://bitbucket.org/ged/fluent_fixtures
82
+ [github]: https://github.com/ged/fluent_fixtures
83
+
@@ -7,7 +7,11 @@ require 'loggability'
7
7
  require 'fluent_fixtures' unless defined?( FluentFixtures )
8
8
 
9
9
 
10
- # Extension module for fixture collection modules
10
+ # The extension module for declaring a collection of fixtures. It has three
11
+ # responsibilities: it makes the Module an extension itself for setting up
12
+ # individual fixture modules, it adds the methods for loading fixtures by name
13
+ # (or loading them all), and it adds data structures to the extended module so
14
+ # it can serve as a repository for loaded fixtures.
11
15
  module FluentFixtures::Collection
12
16
  extend Loggability
13
17
 
@@ -129,15 +129,17 @@ class FluentFixtures::Factory
129
129
 
130
130
 
131
131
  ### Return an infinite generator for unsaved instances of the fixtured object.
132
- def generator( create: false, limit: DEFAULT_GENERATOR_LIMIT )
132
+ def generator( create: false, limit: DEFAULT_GENERATOR_LIMIT, &block )
133
133
  return Enumerator.new( limit || Float::INFINITY ) do |yielder|
134
134
  count = 0
135
+ constructor = create ? :create : :instance
135
136
  loop do
136
137
  break if limit && count >= limit
137
- obj = if create
138
- self.create
138
+
139
+ obj = if block
140
+ self.send( constructor, &block.curry(2)[count] )
139
141
  else
140
- self.instance
142
+ self.send( constructor )
141
143
  end
142
144
 
143
145
  yielder.yield( obj )
@@ -5,16 +5,29 @@
5
5
  require 'loggability'
6
6
 
7
7
 
8
- # Fluent fixtures
8
+ # A toolkit for building testing objects with a fluent interface.
9
+ #
10
+ # The three main parts of fluent_fixtures are the Collection extension module,
11
+ # the DSL module, and the Factory class.
12
+ #
13
+ # The Collection is what you extend a Module with when you're setting up a
14
+ # collection of fixtures for a particular codebase.
15
+ #
16
+ # The DSL module contains methods for declaring individual fixtures for a
17
+ # Collection.
18
+ #
19
+ # Factories are the objects that provide the fluent interface set up by the
20
+ # decorators that evetually create the fixtured objects.
21
+ #
9
22
  module FluentFixtures
10
23
  extend Loggability
11
24
 
12
25
 
13
26
  # Package version
14
- VERSION = '0.5.0'
27
+ VERSION = '0.6.0'
15
28
 
16
29
  # Version control revision
17
- REVISION = %q$Revision: ed67198925b5 $
30
+ REVISION = %q$Revision: 3d6408efbde6 $
18
31
 
19
32
 
20
33
  # Loggability API -- set up a named logger
@@ -386,6 +386,21 @@ describe FluentFixtures::Factory do
386
386
  expect( enum.size ).to eq( Float::INFINITY )
387
387
  end
388
388
 
389
+
390
+ it "yields each new object and the index to a block passed to the generator" do
391
+ enum = factory.generator do |i, obj|
392
+ obj.email = "user#{i}@example.com"
393
+ end
394
+
395
+ instances = enum.take( 5 )
396
+
397
+ expect( instances[0].email ).to eq( 'user0@example.com' )
398
+ expect( instances[1].email ).to eq( 'user1@example.com' )
399
+ expect( instances[2].email ).to eq( 'user2@example.com' )
400
+ expect( instances[3].email ).to eq( 'user3@example.com' )
401
+ expect( instances[4].email ).to eq( 'user4@example.com' )
402
+ end
403
+
389
404
  end
390
405
 
391
406
  end
data.tar.gz.sig CHANGED
Binary file
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
36
36
  p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
37
37
  -----END CERTIFICATE-----
38
- date: 2017-05-16 00:00:00.000000000 Z
38
+ date: 2017-06-27 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: loggability
@@ -85,14 +85,14 @@ dependencies:
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.8'
88
+ version: '0.9'
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.8'
95
+ version: '0.9'
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: hoe-highline
98
98
  requirement: !ruby/object:Gem::Requirement
@@ -169,14 +169,14 @@ dependencies:
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '3.15'
172
+ version: '3.16'
173
173
  type: :development
174
174
  prerelease: false
175
175
  version_requirements: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: '3.15'
179
+ version: '3.16'
180
180
  description: |-
181
181
  FluentFixtures is a toolkit for building testing objects with a fluent interface.
182
182
 
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  requirements: []
239
239
  rubyforge_project:
240
- rubygems_version: 2.6.8
240
+ rubygems_version: 2.6.12
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