tfg_support 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TFG::Support
2
2
 
3
- A collection of handy helpers and extentions to the Ruby core library.
3
+ A collection of handy helpers and extensions to the Ruby core library.
4
4
  Should only contain application-nonspecific code that is of general use.
5
5
 
6
6
  ## Installation
@@ -35,4 +35,4 @@ This project uses [Semantic Versioning](http://semver.org).
35
35
  2. Create your feature branch (`git checkout -b my-new-feature`)
36
36
  3. Commit your changes (`git commit -am 'Add some feature'`)
37
37
  4. Push to the branch (`git push origin my-new-feature`)
38
- 5. Create a Pull Request
38
+ 5. Create a Pull Request
@@ -1,9 +1,9 @@
1
1
  module TFG
2
2
  module Support
3
3
  class Sequence
4
- def initialize(first, generator)
4
+ def initialize(first, generator=nil, &block)
5
5
  self.first = first
6
- self.generator = generator
6
+ self.generator = generator || block
7
7
  end
8
8
 
9
9
  def next
@@ -1,5 +1,5 @@
1
1
  module TFG
2
2
  module Support
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -1,25 +1,50 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe TFG::Support::Sequence do
4
- subject(:sequence) { TFG::Support::Sequence.new(first, generator) }
4
+ context 'created with a generator' do
5
+ subject(:sequence) { TFG::Support::Sequence.new(first, generator) }
5
6
 
6
- describe "#next" do
7
- let(:first) { Object.new }
8
- let(:second) { Object.new }
9
- let(:generator) { double("generator", call: second) }
7
+ describe "#next" do
8
+ let(:first) { Object.new }
9
+ let(:second) { Object.new }
10
+ let(:generator) { double("generator", call: second) }
10
11
 
11
- subject(:call) { sequence.next }
12
+ subject(:next_call) { sequence.next }
12
13
 
13
- context "on the first call" do
14
- specify { expect(call).to eq first }
15
- specify { call; expect(generator).to_not have_received(:call) }
14
+ context "on the first call to next" do
15
+ specify { should eq first }
16
+ end
17
+
18
+ context "on subsequent calls to next" do
19
+ before { sequence.next }
20
+
21
+ specify { should eq second }
22
+ end
16
23
  end
24
+ end
25
+
26
+ context 'created with a block' do
27
+ subject(:sequence) { TFG::Support::Sequence.new(1) { |arg| arg * 2 } }
28
+
29
+ describe '#next' do
30
+ subject(:next_call) { sequence.next }
17
31
 
18
- context "on susequent calls" do
19
- before { sequence.next }
32
+ context "on the first call to next" do
33
+ specify { should eq 1 }
34
+ end
35
+
36
+ context "on the 2nd call to next" do
37
+ before { sequence.next }
38
+ specify { should eq 2 }
39
+ end
40
+
41
+ context "on the 3rd call to next" do
42
+ before { sequence.next; sequence.next }
43
+ specify { should eq 4 }
44
+ end
20
45
 
21
- specify { expect(call).to eq second }
22
- specify { call; expect(generator).to have_received(:call).with(first) }
23
46
  end
47
+
24
48
  end
25
- end
49
+
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfg_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-26 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler