tfg_support 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/tfg/support/sequence.rb +2 -2
- data/lib/tfg/support/version.rb +1 -1
- data/spec/tfg/support/sequence_spec.rb +39 -14
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TFG::Support
|
2
2
|
|
3
|
-
A collection of handy helpers and
|
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
|
data/lib/tfg/support/sequence.rb
CHANGED
data/lib/tfg/support/version.rb
CHANGED
@@ -1,25 +1,50 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe TFG::Support::Sequence do
|
4
|
-
|
4
|
+
context 'created with a generator' do
|
5
|
+
subject(:sequence) { TFG::Support::Sequence.new(first, generator) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
describe "#next" do
|
8
|
+
let(:first) { Object.new }
|
9
|
+
let(:second) { Object.new }
|
10
|
+
let(:generator) { double("generator", call: second) }
|
10
11
|
|
11
|
-
|
12
|
+
subject(:next_call) { sequence.next }
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
19
|
-
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|