state_machine_rspec 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/state_machine_rspec/version.rb +1 -1
- data/spec/integration/integration_spec.rb +65 -65
- data/spec/matchers/events/handle_event_spec.rb +13 -15
- data/spec/matchers/events/reject_event_spec.rb +13 -15
- data/spec/matchers/states/have_state_spec.rb +11 -11
- data/spec/matchers/states/reject_state_spec.rb +10 -12
- data/spec/spec_helper.rb +1 -1
- data/state_machine_rspec.gemspec +2 -1
- metadata +43 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e99182af13ca07fd2150ee967c76d2b073825167
|
4
|
+
data.tar.gz: 7bd24b4614e7ab6dbe73edf0b43d9c98485844b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 83006733670b8863de78064eeba34b0373f05ea323aadd3ac51cc45474aca8bc9c74a60e69582c68a081f0e26256ddc6ed7ad6a587870355817c9997f439bbb7
|
7
|
+
data.tar.gz: 1acce1d0830d88407a84f85c3227f343d77f1091dc4fc15c24a95e500ef0f987e9907168c41de3a3c34d0ac0ce8ef2b580a6b1a446b1ffb74959090bb4a7772a
|
@@ -5,25 +5,25 @@ describe Vehicle do
|
|
5
5
|
let(:vehicle) { Vehicle.new }
|
6
6
|
subject { vehicle }
|
7
7
|
|
8
|
-
its(:passed_inspection?) {
|
8
|
+
its(:passed_inspection?) { is_expected.to be_falsey }
|
9
9
|
|
10
10
|
shared_examples 'crashable' do
|
11
11
|
describe 'crash' do
|
12
12
|
context 'having passed inspection' do
|
13
|
-
before { vehicle.
|
13
|
+
before { allow(vehicle).to receive_messages(:passed_inspection => true) }
|
14
14
|
pending 'keeps running' do
|
15
15
|
initial_state = vehicle.state
|
16
16
|
vehicle.crash!
|
17
17
|
|
18
|
-
vehicle.state.
|
18
|
+
expect(vehicle.state).to eq initial_state
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'not having passed inspection' do
|
23
|
-
before { vehicle.
|
23
|
+
before { allow(vehicle).to receive_messages(:passed_inspection => false) }
|
24
24
|
it 'stalls' do
|
25
25
|
vehicle.crash!
|
26
|
-
vehicle.state.
|
26
|
+
expect(vehicle.state).to eq :stalled.to_s
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -36,9 +36,9 @@ describe Vehicle do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe '#initialize' do
|
39
|
-
its(:seatbelt_on) {
|
40
|
-
its(:time_used) {
|
41
|
-
its(:auto_shop_busy) {
|
39
|
+
its(:seatbelt_on) { is_expected.to be_falsey }
|
40
|
+
its(:time_used) { is_expected.to eq 0 }
|
41
|
+
its(:auto_shop_busy) { is_expected.to be_truthy }
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#put_on_seatbelt' do
|
@@ -46,53 +46,53 @@ describe Vehicle do
|
|
46
46
|
vehicle.seatbelt_on = false
|
47
47
|
vehicle.put_on_seatbelt
|
48
48
|
|
49
|
-
vehicle.seatbelt_on.
|
49
|
+
expect(vehicle.seatbelt_on).to be_truthy
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'state machine' do
|
54
|
-
it {
|
54
|
+
it { is_expected.to have_states :parked, :idling, :stalled, :first_gear,
|
55
55
|
:second_gear, :third_gear }
|
56
|
-
it {
|
56
|
+
it { is_expected.to reject_state :flying }
|
57
57
|
|
58
|
-
it {
|
59
|
-
it {
|
58
|
+
it { is_expected.to handle_event :ignite, when: :parked }
|
59
|
+
it { is_expected.to reject_events :park, :idle, :shift_up,
|
60
60
|
:shift_down, :crash, :repair,
|
61
61
|
when: :parked }
|
62
62
|
|
63
|
-
it {
|
64
|
-
it {
|
63
|
+
it { is_expected.to handle_events :park, :shift_up, :crash, when: :idling }
|
64
|
+
it { is_expected.to reject_events :ignite, :idle, :shift_down, :repair,
|
65
65
|
when: :idling }
|
66
66
|
|
67
|
-
it {
|
68
|
-
it {
|
67
|
+
it { is_expected.to handle_events :ignite, :repair, when: :stalled }
|
68
|
+
it { is_expected.to reject_events :park, :idle, :shift_up, :shift_down, :crash,
|
69
69
|
when: :stalled }
|
70
70
|
|
71
|
-
it {
|
71
|
+
it { is_expected.to handle_events :park, :idle, :shift_up, :crash,
|
72
72
|
when: :first_gear }
|
73
|
-
it {
|
73
|
+
it { is_expected.to reject_events :ignite, :shift_down, :repair,
|
74
74
|
when: :first_gear }
|
75
75
|
|
76
|
-
it {
|
76
|
+
it { is_expected.to handle_events :shift_up, :shift_down, :crash,
|
77
77
|
when: :second_gear }
|
78
|
-
it {
|
78
|
+
it { is_expected.to reject_events :park, :ignite, :idle, :repair,
|
79
79
|
when: :second_gear }
|
80
80
|
|
81
|
-
it {
|
82
|
-
it {
|
81
|
+
it { is_expected.to handle_events :shift_down, :crash, when: :third_gear }
|
82
|
+
it { is_expected.to reject_events :park, :ignite, :idle, :shift_up, :repair,
|
83
83
|
when: :third_gear }
|
84
84
|
|
85
85
|
it 'has an initial state of "parked"' do
|
86
|
-
vehicle.
|
86
|
+
expect(vehicle).to be_parked
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'has an initial alarm state of "active"' do
|
90
|
-
vehicle.alarm_active
|
90
|
+
expect(vehicle.alarm_active?).to be_truthy
|
91
91
|
end
|
92
92
|
|
93
93
|
describe 'around transitions' do
|
94
94
|
it 'updates the time used' do
|
95
|
-
vehicle.
|
95
|
+
expect(vehicle).to receive(:time_used=).with(0)
|
96
96
|
Timecop.freeze { vehicle.ignite! }
|
97
97
|
end
|
98
98
|
end
|
@@ -100,12 +100,12 @@ describe Vehicle do
|
|
100
100
|
context 'when parked' do
|
101
101
|
before { vehicle.state = :parked.to_s }
|
102
102
|
|
103
|
-
its(:speed) {
|
104
|
-
it {
|
103
|
+
its(:speed) { is_expected.to be_zero }
|
104
|
+
it { is_expected.not_to be_moving }
|
105
105
|
|
106
106
|
describe 'before transitions' do
|
107
107
|
it 'puts on a seatbelt' do
|
108
|
-
vehicle.
|
108
|
+
expect(vehicle).to receive :put_on_seatbelt
|
109
109
|
vehicle.ignite!
|
110
110
|
end
|
111
111
|
end
|
@@ -113,7 +113,7 @@ describe Vehicle do
|
|
113
113
|
describe 'ignite' do
|
114
114
|
it 'should transition to idling' do
|
115
115
|
vehicle.ignite!
|
116
|
-
vehicle.
|
116
|
+
expect(vehicle).to be_idling
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -121,7 +121,7 @@ describe Vehicle do
|
|
121
121
|
context 'when transitioning to parked' do
|
122
122
|
before { vehicle.state = :idling.to_s }
|
123
123
|
it 'removes seatbelts' do
|
124
|
-
vehicle.
|
124
|
+
expect(vehicle).to receive(:seatbelt_on=).with(false)
|
125
125
|
vehicle.park!
|
126
126
|
end
|
127
127
|
end
|
@@ -129,20 +129,20 @@ describe Vehicle do
|
|
129
129
|
context 'when idling' do
|
130
130
|
before { vehicle.state = :idling.to_s }
|
131
131
|
|
132
|
-
its(:speed) {
|
133
|
-
it {
|
132
|
+
its(:speed) { is_expected.to eq 10 }
|
133
|
+
it { is_expected.not_to be_moving }
|
134
134
|
|
135
135
|
describe 'park' do
|
136
136
|
it 'should transition to a parked state' do
|
137
137
|
vehicle.park!
|
138
|
-
vehicle.
|
138
|
+
expect(vehicle).to be_parked
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
142
|
describe 'shift up' do
|
143
143
|
it 'should shift into first gear' do
|
144
144
|
vehicle.shift_up!
|
145
|
-
vehicle.
|
145
|
+
expect(vehicle).to be_first_gear
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -152,30 +152,30 @@ describe Vehicle do
|
|
152
152
|
context 'when stalled' do
|
153
153
|
before { vehicle.state = :stalled.to_s }
|
154
154
|
|
155
|
-
it {
|
155
|
+
it { is_expected.not_to be_moving }
|
156
156
|
it_behaves_like 'speedless'
|
157
157
|
|
158
158
|
describe 'ignite' do
|
159
159
|
it 'remains stalled' do
|
160
160
|
vehicle.ignite!
|
161
|
-
vehicle.
|
161
|
+
expect(vehicle).to be_stalled
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
describe 'repair' do
|
166
166
|
context 'the auto shop is busy' do
|
167
|
-
before { vehicle.
|
167
|
+
before { allow(vehicle).to receive_messages(:auto_shop_busy => true) }
|
168
168
|
it 'remains stalled' do
|
169
169
|
vehicle.repair!
|
170
|
-
vehicle.
|
170
|
+
expect(vehicle).to be_stalled
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
174
|
context 'the auto shop is not busy' do
|
175
|
-
before { vehicle.
|
175
|
+
before { allow(vehicle).to receive_messages(:auto_shop_busy => false) }
|
176
176
|
it 'is parked' do
|
177
177
|
vehicle.repair!
|
178
|
-
vehicle.
|
178
|
+
expect(vehicle).to be_parked
|
179
179
|
end
|
180
180
|
end
|
181
181
|
end
|
@@ -184,27 +184,27 @@ describe Vehicle do
|
|
184
184
|
context 'when in first gear' do
|
185
185
|
before { vehicle.state = :first_gear.to_s }
|
186
186
|
|
187
|
-
its(:speed) {
|
188
|
-
it {
|
187
|
+
its(:speed) { is_expected.to eq 10 }
|
188
|
+
it { is_expected.to be_moving }
|
189
189
|
|
190
190
|
describe 'park' do
|
191
191
|
it 'parks' do
|
192
192
|
vehicle.park!
|
193
|
-
vehicle.
|
193
|
+
expect(vehicle).to be_parked
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
describe 'idle' do
|
198
198
|
it 'idles' do
|
199
199
|
vehicle.idle!
|
200
|
-
vehicle.
|
200
|
+
expect(vehicle).to be_idling
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
204
|
describe 'shift up' do
|
205
205
|
it 'shift into second gear' do
|
206
206
|
vehicle.shift_up!
|
207
|
-
vehicle.
|
207
|
+
expect(vehicle).to be_second_gear
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -214,20 +214,20 @@ describe Vehicle do
|
|
214
214
|
context 'when in second gear' do
|
215
215
|
before { vehicle.state = :second_gear.to_s }
|
216
216
|
|
217
|
-
it {
|
217
|
+
it { is_expected.to be_moving }
|
218
218
|
it_behaves_like 'speedless'
|
219
219
|
|
220
220
|
describe 'shift up' do
|
221
221
|
it 'shifts into third gear' do
|
222
222
|
vehicle.shift_up!
|
223
|
-
vehicle.
|
223
|
+
expect(vehicle).to be_third_gear
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
227
|
describe 'shift down' do
|
228
228
|
it 'shifts back into first gear' do
|
229
229
|
vehicle.shift_down!
|
230
|
-
vehicle.
|
230
|
+
expect(vehicle).to be_first_gear
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
@@ -237,13 +237,13 @@ describe Vehicle do
|
|
237
237
|
context 'when in third gear' do
|
238
238
|
before { vehicle.state = :third_gear.to_s }
|
239
239
|
|
240
|
-
it {
|
240
|
+
it { is_expected.to be_moving }
|
241
241
|
it_behaves_like 'speedless'
|
242
242
|
|
243
243
|
describe 'shift down' do
|
244
244
|
it 'shifts back into second gear' do
|
245
245
|
vehicle.shift_down!
|
246
|
-
vehicle.
|
246
|
+
expect(vehicle).to be_second_gear
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
@@ -252,9 +252,9 @@ describe Vehicle do
|
|
252
252
|
|
253
253
|
context 'on ignition' do
|
254
254
|
context 'when it fails' do
|
255
|
-
before { vehicle.
|
255
|
+
before { allow(vehicle).to receive_messages(:ignite => false) }
|
256
256
|
pending 'logs the failure' do
|
257
|
-
vehicle.
|
257
|
+
expect(vehicle).to receive(:log_start_failure)
|
258
258
|
vehicle.ignite
|
259
259
|
end
|
260
260
|
end
|
@@ -263,7 +263,7 @@ describe Vehicle do
|
|
263
263
|
context 'on a crash' do
|
264
264
|
before { vehicle.state = :third_gear.to_s }
|
265
265
|
it 'gets towed' do
|
266
|
-
vehicle.
|
266
|
+
expect(vehicle).to receive(:tow)
|
267
267
|
vehicle.crash!
|
268
268
|
end
|
269
269
|
end
|
@@ -271,38 +271,38 @@ describe Vehicle do
|
|
271
271
|
context 'upon being repaired' do
|
272
272
|
before { vehicle.state = :stalled.to_s }
|
273
273
|
it 'gets fixed' do
|
274
|
-
vehicle.
|
274
|
+
expect(vehicle).to receive(:fix)
|
275
275
|
vehicle.repair!
|
276
276
|
end
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
280
|
describe 'alarm state machine' do
|
281
|
-
it {
|
282
|
-
it {
|
283
|
-
it {
|
281
|
+
it { is_expected.to have_state :active, on: :alarm_state, value: 1 }
|
282
|
+
it { is_expected.to have_state :off, on: :alarm_state, value: 0 }
|
283
|
+
it { is_expected.to reject_states :broken, :ringing, on: :alarm_state }
|
284
284
|
|
285
|
-
it {
|
285
|
+
it { is_expected.to handle_events :enable_alarm, :disable_alarm,
|
286
286
|
when: :active, on: :alarm_state }
|
287
|
-
it {
|
287
|
+
it { is_expected.to handle_events :enable_alarm, :disable_alarm,
|
288
288
|
when: :off, on: :alarm_state }
|
289
289
|
|
290
290
|
it 'has an initial state of activated' do
|
291
|
-
vehicle.alarm_active
|
291
|
+
expect(vehicle.alarm_active?).to be_truthy
|
292
292
|
end
|
293
293
|
|
294
294
|
context 'when active' do
|
295
295
|
describe 'enable' do
|
296
296
|
it 'becomes active' do
|
297
297
|
vehicle.enable_alarm!
|
298
|
-
vehicle.alarm_active
|
298
|
+
expect(vehicle.alarm_active?).to be_truthy
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
302
|
describe 'disable' do
|
303
303
|
it 'turns the alarm off' do
|
304
304
|
vehicle.disable_alarm!
|
305
|
-
vehicle.alarm_off
|
305
|
+
expect(vehicle.alarm_off?).to be_truthy
|
306
306
|
end
|
307
307
|
end
|
308
308
|
end
|
@@ -312,14 +312,14 @@ describe Vehicle do
|
|
312
312
|
describe 'enable' do
|
313
313
|
it 'becomes active' do
|
314
314
|
vehicle.enable_alarm!
|
315
|
-
vehicle.alarm_active
|
315
|
+
expect(vehicle.alarm_active?).to be_truthy
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
319
|
describe 'disable' do
|
320
320
|
it 'turns the alarm off' do
|
321
321
|
vehicle.disable_alarm!
|
322
|
-
vehicle.alarm_off
|
322
|
+
expect(vehicle.alarm_off?).to be_truthy
|
323
323
|
end
|
324
324
|
end
|
325
325
|
end
|
@@ -31,7 +31,7 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
31
31
|
|
32
32
|
it 'sets the state' do
|
33
33
|
@matcher.matches? @matcher_subject
|
34
|
-
@matcher_subject.state.
|
34
|
+
expect(@matcher_subject.state).to eq 'artsy'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -49,10 +49,10 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
49
49
|
|
50
50
|
it 'does not set a failure message' do
|
51
51
|
@matcher.matches? @matcher_subject
|
52
|
-
@matcher.failure_message.
|
52
|
+
expect(@matcher.failure_message).to be_nil
|
53
53
|
end
|
54
54
|
it 'returns true' do
|
55
|
-
@matcher.matches?(@matcher_subject).
|
55
|
+
expect(@matcher.matches?(@matcher_subject)).to be_truthy
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -77,12 +77,11 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
77
77
|
|
78
78
|
it 'sets a failure message' do
|
79
79
|
@matcher.matches? @matcher_subject
|
80
|
-
@matcher.failure_message.
|
81
|
-
|
82
|
-
'in state: mathy'
|
80
|
+
expect(@matcher.failure_message).to eq('Expected to be able to handle events: algebraify, trigonomalize ' +
|
81
|
+
'in state: mathy')
|
83
82
|
end
|
84
83
|
it 'returns false' do
|
85
|
-
@matcher.matches?(@matcher_subject).
|
84
|
+
expect(@matcher.matches?(@matcher_subject)).to be_falsey
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
@@ -92,16 +91,15 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
92
91
|
end
|
93
92
|
|
94
93
|
it 'does not raise' do
|
95
|
-
expect { @matcher.matches?(@matcher_subject) }.
|
94
|
+
expect { @matcher.matches?(@matcher_subject) }.not_to raise_error
|
96
95
|
end
|
97
96
|
it 'sets a failure message' do
|
98
97
|
@matcher.matches? @matcher_subject
|
99
|
-
@matcher.failure_message.
|
100
|
-
|
101
|
-
'define events: polynomialize, eulerasterize'
|
98
|
+
expect(@matcher.failure_message).to eq('state_machine: state does not ' +
|
99
|
+
'define events: polynomialize, eulerasterize')
|
102
100
|
end
|
103
101
|
it 'returns false' do
|
104
|
-
@matcher.matches?(@matcher_subject).
|
102
|
+
expect(@matcher.matches?(@matcher_subject)).to be_falsey
|
105
103
|
end
|
106
104
|
end
|
107
105
|
end
|
@@ -112,7 +110,7 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
112
110
|
let(:matcher) { described_class.new([:placate, :mollify]) }
|
113
111
|
|
114
112
|
it 'returns a string description' do
|
115
|
-
matcher.description.
|
113
|
+
expect(matcher.description).to eq('handle :placate, :mollify')
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
@@ -120,7 +118,7 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
120
118
|
let(:matcher) { described_class.new([:destroy_food, when: :hangry]) }
|
121
119
|
|
122
120
|
it 'mentions the requisite state' do
|
123
|
-
matcher.description.
|
121
|
+
expect(matcher.description).to eq('handle :destroy_food when :hangry')
|
124
122
|
end
|
125
123
|
end
|
126
124
|
|
@@ -128,7 +126,7 @@ describe StateMachineRspec::Matchers::HandleEventMatcher do
|
|
128
126
|
let(:matcher) { described_class.new([:ensmarmify, on: :tired_investors]) }
|
129
127
|
|
130
128
|
it 'mentions the state machine variable' do
|
131
|
-
matcher.description.
|
129
|
+
expect(matcher.description).to eq('handle :ensmarmify on :tired_investors')
|
132
130
|
end
|
133
131
|
end
|
134
132
|
end
|
@@ -31,7 +31,7 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
31
31
|
|
32
32
|
it 'sets the state' do
|
33
33
|
@matcher.matches? @matcher_subject
|
34
|
-
@matcher_subject.state.
|
34
|
+
expect(@matcher_subject.state).to eq('sneezy')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -48,16 +48,15 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'does not raise' do
|
51
|
-
expect { @matcher.matches?(@matcher_subject) }.
|
51
|
+
expect { @matcher.matches?(@matcher_subject) }.not_to raise_error
|
52
52
|
end
|
53
53
|
it 'sets a failure message' do
|
54
54
|
@matcher.matches? @matcher_subject
|
55
|
-
@matcher.failure_message.
|
56
|
-
|
57
|
-
'define events: martinilunchitize'
|
55
|
+
expect(@matcher.failure_message).to eq('state_machine: state does not ' +
|
56
|
+
'define events: martinilunchitize')
|
58
57
|
end
|
59
58
|
it 'returns false' do
|
60
|
-
@matcher.matches?(@matcher_subject).
|
59
|
+
expect(@matcher.matches?(@matcher_subject)).to be_falsey
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
@@ -75,10 +74,10 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
75
74
|
|
76
75
|
it 'does not set a failure message' do
|
77
76
|
@matcher.matches? @matcher_subject
|
78
|
-
@matcher.failure_message.
|
77
|
+
expect(@matcher.failure_message).to be_nil
|
79
78
|
end
|
80
79
|
it 'returns true' do
|
81
|
-
@matcher.matches?(@matcher_subject).
|
80
|
+
expect(@matcher.matches?(@matcher_subject)).to be_truthy
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -97,12 +96,11 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
97
96
|
|
98
97
|
it 'sets a failure message' do
|
99
98
|
@matcher.matches? @matcher_subject
|
100
|
-
@matcher.failure_message.
|
101
|
-
|
102
|
-
'in state: snarky'
|
99
|
+
expect(@matcher.failure_message).to eq('Did not expect to be able to handle events: defer_to_management ' +
|
100
|
+
'in state: snarky')
|
103
101
|
end
|
104
102
|
it 'returns false' do
|
105
|
-
@matcher.matches?(@matcher_subject).
|
103
|
+
expect(@matcher.matches?(@matcher_subject)).to be_falsey
|
106
104
|
end
|
107
105
|
end
|
108
106
|
end
|
@@ -112,7 +110,7 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
112
110
|
let(:matcher) { described_class.new([:makeadealify, :hustlinate]) }
|
113
111
|
|
114
112
|
it 'returns a string description' do
|
115
|
-
matcher.description.
|
113
|
+
expect(matcher.description).to eq('reject :makeadealify, :hustlinate')
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
@@ -120,7 +118,7 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
120
118
|
let(:matcher) { described_class.new([:begargle, when: :sleep_encrusted]) }
|
121
119
|
|
122
120
|
it 'mentions the requisite state' do
|
123
|
-
matcher.description.
|
121
|
+
expect(matcher.description).to eq('reject :begargle when :sleep_encrusted')
|
124
122
|
end
|
125
123
|
end
|
126
124
|
|
@@ -128,7 +126,7 @@ describe StateMachineRspec::Matchers::RejectEventMatcher do
|
|
128
126
|
let(:matcher) { described_class.new([:harrangue, on: :suspicious_crowd]) }
|
129
127
|
|
130
128
|
it 'mentions the state machine variable' do
|
131
|
-
matcher.description.
|
129
|
+
expect(matcher.description).to eq('reject :harrangue on :suspicious_crowd')
|
132
130
|
end
|
133
131
|
end
|
134
132
|
end
|
@@ -40,10 +40,10 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
40
40
|
|
41
41
|
it 'sets a failure message indicating a state is missing' do
|
42
42
|
@matcher.matches? @class.new
|
43
|
-
@matcher.failure_message.
|
43
|
+
expect(@matcher.failure_message).to eq 'Expected radical_state to allow states: rad'
|
44
44
|
end
|
45
45
|
it 'returns false' do
|
46
|
-
@matcher.matches?(@class.new).
|
46
|
+
expect(@matcher.matches?(@class.new)).to be_falsey
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -60,10 +60,10 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
60
60
|
context 'state values not specified' do
|
61
61
|
it 'does not set a failure message' do
|
62
62
|
@matcher.matches? @class.new
|
63
|
-
@matcher.failure_message.
|
63
|
+
expect(@matcher.failure_message).to be_nil
|
64
64
|
end
|
65
65
|
it 'returns true' do
|
66
|
-
@matcher.matches?(@class.new).
|
66
|
+
expect(@matcher.matches?(@class.new)).to be_truthy
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -79,10 +79,10 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
79
79
|
|
80
80
|
it 'does not set a failure message' do
|
81
81
|
@matcher.matches? @class.new
|
82
|
-
@matcher.failure_message.
|
82
|
+
expect(@matcher.failure_message).to be_nil
|
83
83
|
end
|
84
84
|
it 'returns true' do
|
85
|
-
@matcher.matches?(@class.new).
|
85
|
+
expect(@matcher.matches?(@class.new)).to be_truthy
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -98,10 +98,10 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
98
98
|
|
99
99
|
it 'does not set a failure message' do
|
100
100
|
@matcher.matches? @class.new
|
101
|
-
@matcher.failure_message.
|
101
|
+
expect(@matcher.failure_message).to eq 'Expected rad to have value uber-rad'
|
102
102
|
end
|
103
103
|
it 'returns true' do
|
104
|
-
@matcher.matches?(@class.new).
|
104
|
+
expect(@matcher.matches?(@class.new)).to be_falsey
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -113,7 +113,7 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
113
113
|
let(:matcher) { described_class.new([:fancy_shirt, :cracked_toenail]) }
|
114
114
|
|
115
115
|
it 'returns a string description' do
|
116
|
-
matcher.description.
|
116
|
+
expect(matcher.description).to eq('have :fancy_shirt, :cracked_toenail')
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -121,7 +121,7 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
121
121
|
let(:matcher) { described_class.new([:mustache, value: :really_shady]) }
|
122
122
|
|
123
123
|
it 'mentions the requisite state' do
|
124
|
-
matcher.description.
|
124
|
+
expect(matcher.description).to eq('have :mustache == :really_shady')
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -129,7 +129,7 @@ describe StateMachineRspec::Matchers::HaveStateMatcher do
|
|
129
129
|
let(:matcher) { described_class.new([:lunch, on: :tuesday]) }
|
130
130
|
|
131
131
|
it 'mentions the state machine variable' do
|
132
|
-
matcher.description.
|
132
|
+
expect(matcher.description).to eq('have :lunch on :tuesday')
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -21,11 +21,10 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
21
21
|
|
22
22
|
it 'sets a failure message' do
|
23
23
|
@matcher.matches? @class.new
|
24
|
-
@matcher.failure_message.
|
25
|
-
should eq 'Did not expect environment to allow states: supportive'
|
24
|
+
expect(@matcher.failure_message).to eq('Did not expect environment to allow states: supportive')
|
26
25
|
end
|
27
26
|
it 'returns false' do
|
28
|
-
@matcher.matches?(@class.new).
|
27
|
+
expect(@matcher.matches?(@class.new)).to be_falsey
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -38,10 +37,10 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
38
37
|
|
39
38
|
it 'does not set a failure message' do
|
40
39
|
@matcher.matches? @class.new
|
41
|
-
@matcher.failure_message.
|
40
|
+
expect(@matcher.failure_message).to be_nil
|
42
41
|
end
|
43
42
|
it 'returns true' do
|
44
|
-
@matcher.matches?(@class.new).
|
43
|
+
expect(@matcher.matches?(@class.new)).to be_truthy
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
@@ -58,11 +57,10 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
58
57
|
|
59
58
|
it 'sets a failure message' do
|
60
59
|
@matcher.matches? @class.new
|
61
|
-
@matcher.failure_message.
|
62
|
-
should eq 'Did not expect state to allow states: ever_changing'
|
60
|
+
expect(@matcher.failure_message).to eq('Did not expect state to allow states: ever_changing')
|
63
61
|
end
|
64
62
|
it 'returns false' do
|
65
|
-
@matcher.matches?(@class.new).
|
63
|
+
expect(@matcher.matches?(@class.new)).to be_falsey
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
@@ -70,10 +68,10 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
70
68
|
before { @class = Class.new }
|
71
69
|
it 'does not set a failure message' do
|
72
70
|
@matcher.matches? @class.new
|
73
|
-
@matcher.failure_message.
|
71
|
+
expect(@matcher.failure_message).to be_nil
|
74
72
|
end
|
75
73
|
it 'returns true' do
|
76
|
-
@matcher.matches?(@class.new).
|
74
|
+
expect(@matcher.matches?(@class.new)).to be_truthy
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -84,7 +82,7 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
84
82
|
let(:matcher) { described_class.new([:mustard, :tomatoes]) }
|
85
83
|
|
86
84
|
it 'returns a string description' do
|
87
|
-
matcher.description.
|
85
|
+
expect(matcher.description).to eq('not have :mustard, :tomatoes')
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
@@ -92,7 +90,7 @@ describe StateMachineRspec::Matchers::RejectStateMatcher do
|
|
92
90
|
let(:matcher) { described_class.new([:peanut_butter, on: :toast]) }
|
93
91
|
|
94
92
|
it 'mentions the state machine variable' do
|
95
|
-
matcher.description.
|
93
|
+
expect(matcher.description).to eq('not have :peanut_butter on :toast')
|
96
94
|
end
|
97
95
|
end
|
98
96
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'state_machine'
|
2
2
|
require 'state_machine_rspec'
|
3
3
|
require 'timecop'
|
4
|
+
require 'rspec/its'
|
4
5
|
|
5
6
|
RSpec.configure do |config|
|
6
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
7
|
config.run_all_when_everything_filtered = true
|
8
8
|
config.filter_run :focus
|
9
9
|
config.order = 'random'
|
data/state_machine_rspec.gemspec
CHANGED
@@ -24,8 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'guard-rspec'
|
25
25
|
spec.add_development_dependency 'rb-fsevent'
|
26
26
|
spec.add_development_dependency 'terminal-notifier-guard'
|
27
|
+
spec.add_development_dependency 'rspec-its'
|
27
28
|
|
28
|
-
spec.add_dependency 'rspec', '
|
29
|
+
spec.add_dependency 'rspec', '>= 3.0.0.rc1'
|
29
30
|
spec.add_dependency 'state_machine', '>= 1.1.0'
|
30
31
|
spec.add_dependency 'activesupport'
|
31
32
|
end
|
metadata
CHANGED
@@ -1,161 +1,156 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machine_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- modocache
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: timecop
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: guard-rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rb-fsevent
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: terminal-notifier-guard
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-its
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
- !ruby/object:Gem::Dependency
|
111
112
|
name: rspec
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.0.0.rc1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
121
|
requirements:
|
123
|
-
- -
|
122
|
+
- - '>='
|
124
123
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
124
|
+
version: 3.0.0.rc1
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
126
|
name: state_machine
|
128
127
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
128
|
requirements:
|
131
|
-
- -
|
129
|
+
- - '>='
|
132
130
|
- !ruby/object:Gem::Version
|
133
131
|
version: 1.1.0
|
134
132
|
type: :runtime
|
135
133
|
prerelease: false
|
136
134
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
135
|
requirements:
|
139
|
-
- -
|
136
|
+
- - '>='
|
140
137
|
- !ruby/object:Gem::Version
|
141
138
|
version: 1.1.0
|
142
139
|
- !ruby/object:Gem::Dependency
|
143
140
|
name: activesupport
|
144
141
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
142
|
requirements:
|
147
|
-
- -
|
143
|
+
- - '>='
|
148
144
|
- !ruby/object:Gem::Version
|
149
145
|
version: '0'
|
150
146
|
type: :runtime
|
151
147
|
prerelease: false
|
152
148
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
149
|
requirements:
|
155
|
-
- -
|
150
|
+
- - '>='
|
156
151
|
- !ruby/object:Gem::Version
|
157
152
|
version: '0'
|
158
|
-
description:
|
153
|
+
description: ' RSpec matchers for state_machine. '
|
159
154
|
email:
|
160
155
|
- modocache@gmail.com
|
161
156
|
executables: []
|
@@ -191,27 +186,26 @@ files:
|
|
191
186
|
homepage: http://github.com/modocache/state_machine_rspec
|
192
187
|
licenses:
|
193
188
|
- MIT
|
189
|
+
metadata: {}
|
194
190
|
post_install_message:
|
195
191
|
rdoc_options: []
|
196
192
|
require_paths:
|
197
193
|
- lib
|
198
194
|
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
-
none: false
|
200
195
|
requirements:
|
201
|
-
- -
|
196
|
+
- - '>='
|
202
197
|
- !ruby/object:Gem::Version
|
203
198
|
version: '0'
|
204
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
-
none: false
|
206
200
|
requirements:
|
207
|
-
- -
|
201
|
+
- - '>='
|
208
202
|
- !ruby/object:Gem::Version
|
209
203
|
version: '0'
|
210
204
|
requirements: []
|
211
205
|
rubyforge_project:
|
212
|
-
rubygems_version: 1.
|
206
|
+
rubygems_version: 2.1.5
|
213
207
|
signing_key:
|
214
|
-
specification_version:
|
208
|
+
specification_version: 4
|
215
209
|
summary: RSpec matchers for state_machine.
|
216
210
|
test_files:
|
217
211
|
- spec/integration/integration_spec.rb
|
@@ -221,3 +215,4 @@ test_files:
|
|
221
215
|
- spec/matchers/states/have_state_spec.rb
|
222
216
|
- spec/matchers/states/reject_state_spec.rb
|
223
217
|
- spec/spec_helper.rb
|
218
|
+
has_rdoc:
|