juncture 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/juncture.rb +8 -0
- data/lib/juncture/version.rb +1 -1
- data/spec/juncture_spec.rb +34 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61b996b0d6978fb289c9febfb3e9b847d07b5d0a
|
4
|
+
data.tar.gz: f8c9a2bbded8d77c3b4c77df3efdc7b830806066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86aece69ac367895594029e69211559472e235175bc40ad8acd931440a962782d6143e410d8236059c780ea087447063f6a8b6a8cd9fc035a266604a0db2389e
|
7
|
+
data.tar.gz: e5b85b56992a3e2bee953f026946c9329172784504d45e19384ae5fd722e28e88df92b809105732b72db1a5029e532b67a00e87a68726fe4587903f047a5f5e8
|
data/lib/juncture.rb
CHANGED
@@ -25,6 +25,14 @@ class Juncture
|
|
25
25
|
@current_state = new_state
|
26
26
|
end
|
27
27
|
|
28
|
+
def next
|
29
|
+
if index.nil? || @states[index+1].nil?
|
30
|
+
@current_state = @states[0]
|
31
|
+
else
|
32
|
+
@current_state = @states[index+1]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
28
36
|
def ==(value)
|
29
37
|
@current_state == value
|
30
38
|
end
|
data/lib/juncture/version.rb
CHANGED
data/spec/juncture_spec.rb
CHANGED
@@ -42,6 +42,40 @@ describe Juncture do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe '#next' do
|
46
|
+
it 'moves the state forward one step' do
|
47
|
+
temp = Juncture.new 1, 2, 3, default: 1
|
48
|
+
expect(temp.next).to eq 2
|
49
|
+
expect(temp.state).to eq 2
|
50
|
+
expect(temp.next).to eq 3
|
51
|
+
expect(temp.state).to eq 3
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'resets if on final state' do
|
55
|
+
temp = Juncture.new 1, 2, 3, default: 2
|
56
|
+
expect(temp.next).to eq 3
|
57
|
+
expect(temp.state).to eq 3
|
58
|
+
expect(temp.next).to eq 1
|
59
|
+
expect(temp.state).to eq 1
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'resets if default is nil' do
|
63
|
+
temp = Juncture.new 1, 2, 3
|
64
|
+
expect(temp.next).to eq 1
|
65
|
+
expect(temp.state).to eq 1
|
66
|
+
expect(temp.next).to eq 2
|
67
|
+
expect(temp.state).to eq 2
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'resets if default is not a state' do
|
71
|
+
temp = Juncture.new 1, 2, 3, default: 4
|
72
|
+
expect(temp.next).to eq 1
|
73
|
+
expect(temp.state).to eq 1
|
74
|
+
expect(temp.next).to eq 2
|
75
|
+
expect(temp.state).to eq 2
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
45
79
|
describe '#==' do
|
46
80
|
it 'returns true if matching' do
|
47
81
|
temp = Juncture.new 1, 2, 3, default: 2
|