enum_state_machine 0.1.1 → 0.2.0
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/enum_state_machine.gemspec +4 -6
- data/lib/enum_state_machine/integrations/active_model.rb +23 -24
- data/lib/enum_state_machine/version.rb +1 -1
- data/test/functional/state_machine_test.rb +29 -27
- data/test/test_helper.rb +13 -1
- data/test/unit/assertions_test.rb +10 -4
- data/test/unit/branch_test.rb +65 -52
- data/test/unit/callback_test.rb +29 -29
- data/test/unit/error_test.rb +7 -5
- data/test/unit/eval_helpers_test.rb +2 -2
- data/test/unit/event_collection_test.rb +10 -10
- data/test/unit/event_test.rb +56 -55
- data/test/unit/graph_test.rb +6 -6
- data/test/unit/helper_module_test.rb +1 -1
- data/test/unit/integrations/active_model_test.rb +4 -4
- data/test/unit/integrations/active_record_test.rb +7 -7
- data/test/unit/integrations/base_test.rb +2 -2
- data/test/unit/integrations_test.rb +3 -3
- data/test/unit/invalid_event_test.rb +1 -1
- data/test/unit/invalid_parallel_transition_test.rb +1 -1
- data/test/unit/invalid_transition_test.rb +3 -3
- data/test/unit/machine_collection_test.rb +22 -18
- data/test/unit/machine_test.rb +123 -110
- data/test/unit/matcher_helpers_test.rb +3 -3
- data/test/unit/matcher_test.rb +7 -7
- data/test/unit/node_collection_test.rb +24 -22
- data/test/unit/path_collection_test.rb +17 -11
- data/test/unit/path_test.rb +16 -14
- data/test/unit/state_collection_test.rb +12 -12
- data/test/unit/state_context_test.rb +23 -21
- data/test/unit/state_enum_test.rb +1 -1
- data/test/unit/state_machine_test.rb +2 -2
- data/test/unit/state_test.rb +55 -53
- data/test/unit/transition_collection_test.rb +47 -45
- data/test/unit/transition_test.rb +53 -45
- metadata +14 -50
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class StateCollectionByDefaultTest < Test
|
3
|
+
class StateCollectionByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
6
6
|
@states = EnumStateMachine::StateCollection.new(@machine)
|
@@ -19,7 +19,7 @@ class StateCollectionByDefaultTest < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
class StateCollectionTest < Test
|
22
|
+
class StateCollectionTest < MiniTest::Test
|
23
23
|
def setup
|
24
24
|
@klass = Class.new
|
25
25
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -67,7 +67,7 @@ class StateCollectionTest < Test::Unit::TestCase
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_raise_exception_if_matching_invalid_state
|
70
|
-
|
70
|
+
assert_raises(IndexError) { @states.matches?(@object, :invalid) }
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_should_find_state_for_object_if_value_is_known
|
@@ -87,12 +87,12 @@ class StateCollectionTest < Test::Unit::TestCase
|
|
87
87
|
|
88
88
|
def test_should_raise_exception_if_finding_bang_state_for_object_with_unknown_value
|
89
89
|
@object.state = 'invalid'
|
90
|
-
exception =
|
90
|
+
exception = assert_raises(ArgumentError) { @states.match!(@object) }
|
91
91
|
assert_equal '"invalid" is not a known state value', exception.message
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
class StateCollectionStringTest < Test
|
95
|
+
class StateCollectionStringTest < MiniTest::Test
|
96
96
|
def setup
|
97
97
|
@klass = Class.new
|
98
98
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -126,7 +126,7 @@ class StateCollectionStringTest < Test::Unit::TestCase
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
class StateCollectionWithNamespaceTest < Test
|
129
|
+
class StateCollectionWithNamespaceTest < MiniTest::Test
|
130
130
|
def setup
|
131
131
|
@klass = Class.new
|
132
132
|
@machine = EnumStateMachine::Machine.new(@klass, :namespace => 'vehicle')
|
@@ -145,7 +145,7 @@ class StateCollectionWithNamespaceTest < Test::Unit::TestCase
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
class StateCollectionWithCustomStateValuesTest < Test
|
148
|
+
class StateCollectionWithCustomStateValuesTest < MiniTest::Test
|
149
149
|
def setup
|
150
150
|
@klass = Class.new
|
151
151
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -172,7 +172,7 @@ class StateCollectionWithCustomStateValuesTest < Test::Unit::TestCase
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
class StateCollectionWithStateMatchersTest < Test
|
175
|
+
class StateCollectionWithStateMatchersTest < MiniTest::Test
|
176
176
|
def setup
|
177
177
|
@klass = Class.new
|
178
178
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -199,7 +199,7 @@ class StateCollectionWithStateMatchersTest < Test::Unit::TestCase
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
class StateCollectionWithInitialStateTest < Test
|
202
|
+
class StateCollectionWithInitialStateTest < MiniTest::Test
|
203
203
|
def setup
|
204
204
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
205
205
|
@states = EnumStateMachine::StateCollection.new(@machine)
|
@@ -237,7 +237,7 @@ class StateCollectionWithInitialStateTest < Test::Unit::TestCase
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
-
class StateCollectionWithStateBehaviorsTest < Test
|
240
|
+
class StateCollectionWithStateBehaviorsTest < MiniTest::Test
|
241
241
|
def setup
|
242
242
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
243
243
|
@states = EnumStateMachine::StateCollection.new(@machine)
|
@@ -275,7 +275,7 @@ class StateCollectionWithStateBehaviorsTest < Test::Unit::TestCase
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
|
-
class StateCollectionWithEventTransitionsTest < Test
|
278
|
+
class StateCollectionWithEventTransitionsTest < MiniTest::Test
|
279
279
|
def setup
|
280
280
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
281
281
|
@states = EnumStateMachine::StateCollection.new(@machine)
|
@@ -313,7 +313,7 @@ class StateCollectionWithEventTransitionsTest < Test::Unit::TestCase
|
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
|
-
class StateCollectionWithTransitionCallbacksTest < Test
|
316
|
+
class StateCollectionWithTransitionCallbacksTest < MiniTest::Test
|
317
317
|
def setup
|
318
318
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
319
319
|
@states = EnumStateMachine::StateCollection.new(@machine)
|
@@ -9,7 +9,7 @@ class Validateable
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
class StateContextTest < Test
|
12
|
+
class StateContextTest < MiniTest::Test
|
13
13
|
def setup
|
14
14
|
@klass = Class.new(Validateable)
|
15
15
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -27,7 +27,7 @@ class StateContextTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
class StateContextTransitionTest < Test
|
30
|
+
class StateContextTransitionTest < MiniTest::Test
|
31
31
|
def setup
|
32
32
|
@klass = Class.new
|
33
33
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -37,37 +37,39 @@ class StateContextTransitionTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_should_not_allow_except_to
|
40
|
-
exception =
|
40
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:except_to => :idling) }
|
41
41
|
assert_equal 'Invalid key(s): except_to', exception.message
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_should_not_allow_except_from
|
45
|
-
exception =
|
45
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:except_from => :idling) }
|
46
46
|
assert_equal 'Invalid key(s): except_from', exception.message
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_should_not_allow_implicit_transitions
|
50
|
-
exception =
|
50
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:parked => :idling) }
|
51
51
|
assert_equal 'Invalid key(s): parked', exception.message
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_should_not_allow_except_on
|
55
|
-
exception =
|
55
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:except_on => :park) }
|
56
56
|
assert_equal 'Invalid key(s): except_on', exception.message
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_should_require_on_event
|
60
|
-
exception =
|
60
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:to => :idling) }
|
61
61
|
assert_equal 'Must specify :on event', exception.message
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_should_not_allow_missing_from_and_to
|
65
|
-
exception =
|
65
|
+
exception = assert_raises(ArgumentError) { @state_context.transition(:on => :ignite) }
|
66
66
|
assert_equal 'Must specify either :to or :from state', exception.message
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_should_not_allow_from_and_to
|
70
|
-
exception =
|
70
|
+
exception = assert_raises(ArgumentError) {
|
71
|
+
@state_context.transition(:on => :ignite, :from => :parked, :to => :idling)
|
72
|
+
}
|
71
73
|
assert_equal 'Must specify either :to or :from state', exception.message
|
72
74
|
end
|
73
75
|
|
@@ -130,7 +132,7 @@ class StateContextTransitionTest < Test::Unit::TestCase
|
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
133
|
-
class StateContextWithMatchingTransitionTest < Test
|
135
|
+
class StateContextWithMatchingTransitionTest < MiniTest::Test
|
134
136
|
def setup
|
135
137
|
@klass = Class.new
|
136
138
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -149,14 +151,14 @@ class StateContextWithMatchingTransitionTest < Test::Unit::TestCase
|
|
149
151
|
|
150
152
|
def test_should_have_a_transition
|
151
153
|
transition = @event.transition_for(@object)
|
152
|
-
|
154
|
+
refute_nil transition
|
153
155
|
assert_equal 'parked', transition.from
|
154
156
|
assert_equal 'idling', transition.to
|
155
157
|
assert_equal :ignite, transition.event
|
156
158
|
end
|
157
159
|
end
|
158
160
|
|
159
|
-
class StateContextProxyTest < Test
|
161
|
+
class StateContextProxyTest < MiniTest::Test
|
160
162
|
def setup
|
161
163
|
@klass = Class.new(Validateable)
|
162
164
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -181,7 +183,7 @@ class StateContextProxyTest < Test::Unit::TestCase
|
|
181
183
|
end
|
182
184
|
end
|
183
185
|
|
184
|
-
class StateContextProxyWithoutConditionsTest < Test
|
186
|
+
class StateContextProxyWithoutConditionsTest < MiniTest::Test
|
185
187
|
def setup
|
186
188
|
@klass = Class.new(Validateable)
|
187
189
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -198,7 +200,7 @@ class StateContextProxyWithoutConditionsTest < Test::Unit::TestCase
|
|
198
200
|
end
|
199
201
|
|
200
202
|
def test_should_have_if_option
|
201
|
-
|
203
|
+
refute_nil @options[:if]
|
202
204
|
end
|
203
205
|
|
204
206
|
def test_should_be_false_if_state_is_different
|
@@ -211,7 +213,7 @@ class StateContextProxyWithoutConditionsTest < Test::Unit::TestCase
|
|
211
213
|
end
|
212
214
|
end
|
213
215
|
|
214
|
-
class StateContextProxyWithIfConditionTest < Test
|
216
|
+
class StateContextProxyWithIfConditionTest < MiniTest::Test
|
215
217
|
def setup
|
216
218
|
@klass = Class.new(Validateable)
|
217
219
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -225,7 +227,7 @@ class StateContextProxyWithIfConditionTest < Test::Unit::TestCase
|
|
225
227
|
end
|
226
228
|
|
227
229
|
def test_should_have_if_option
|
228
|
-
|
230
|
+
refute_nil @options[:if]
|
229
231
|
end
|
230
232
|
|
231
233
|
def test_should_be_false_if_state_is_different
|
@@ -274,7 +276,7 @@ class StateContextProxyWithIfConditionTest < Test::Unit::TestCase
|
|
274
276
|
end
|
275
277
|
end
|
276
278
|
|
277
|
-
class StateContextProxyWithMultipleIfConditionsTest < Test
|
279
|
+
class StateContextProxyWithMultipleIfConditionsTest < MiniTest::Test
|
278
280
|
def setup
|
279
281
|
@klass = Class.new(Validateable)
|
280
282
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -305,7 +307,7 @@ class StateContextProxyWithMultipleIfConditionsTest < Test::Unit::TestCase
|
|
305
307
|
end
|
306
308
|
end
|
307
309
|
|
308
|
-
class StateContextProxyWithUnlessConditionTest < Test
|
310
|
+
class StateContextProxyWithUnlessConditionTest < MiniTest::Test
|
309
311
|
def setup
|
310
312
|
@klass = Class.new(Validateable)
|
311
313
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -319,7 +321,7 @@ class StateContextProxyWithUnlessConditionTest < Test::Unit::TestCase
|
|
319
321
|
end
|
320
322
|
|
321
323
|
def test_should_have_if_option
|
322
|
-
|
324
|
+
refute_nil @options[:if]
|
323
325
|
end
|
324
326
|
|
325
327
|
def test_should_be_false_if_state_is_different
|
@@ -368,7 +370,7 @@ class StateContextProxyWithUnlessConditionTest < Test::Unit::TestCase
|
|
368
370
|
end
|
369
371
|
end
|
370
372
|
|
371
|
-
class StateContextProxyWithMultipleUnlessConditionsTest < Test
|
373
|
+
class StateContextProxyWithMultipleUnlessConditionsTest < MiniTest::Test
|
372
374
|
def setup
|
373
375
|
@klass = Class.new(Validateable)
|
374
376
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -399,7 +401,7 @@ class StateContextProxyWithMultipleUnlessConditionsTest < Test::Unit::TestCase
|
|
399
401
|
end
|
400
402
|
end
|
401
403
|
|
402
|
-
class StateContextProxyWithIfAndUnlessConditionsTest < Test
|
404
|
+
class StateContextProxyWithIfAndUnlessConditionsTest < MiniTest::Test
|
403
405
|
def setup
|
404
406
|
@klass = Class.new(Validateable)
|
405
407
|
machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EnumStateMachineByDefaultTest < Test
|
3
|
+
class EnumStateMachineByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@klass = Class.new
|
6
6
|
@machine = @klass.state_machine
|
@@ -11,7 +11,7 @@ class EnumStateMachineByDefaultTest < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
class EnumStateMachineTest < Test
|
14
|
+
class EnumStateMachineTest < MiniTest::Test
|
15
15
|
def setup
|
16
16
|
@klass = Class.new
|
17
17
|
end
|
data/test/unit/state_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class StateByDefaultTest < Test
|
3
|
+
class StateByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
6
6
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -40,14 +40,16 @@ class StateByDefaultTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
class StateTest < Test
|
43
|
+
class StateTest < MiniTest::Test
|
44
44
|
def setup
|
45
45
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
46
46
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_should_raise_exception_if_invalid_option_specified
|
50
|
-
exception =
|
50
|
+
exception = assert_raises(ArgumentError) {
|
51
|
+
EnumStateMachine::State.new(@machine, :parked, :invalid => true)
|
52
|
+
}
|
51
53
|
assert_equal 'Invalid key(s): invalid', exception.message
|
52
54
|
end
|
53
55
|
|
@@ -83,7 +85,7 @@ class StateTest < Test::Unit::TestCase
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
class StateWithoutNameTest < Test
|
88
|
+
class StateWithoutNameTest < MiniTest::Test
|
87
89
|
def setup
|
88
90
|
@klass = Class.new
|
89
91
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -121,7 +123,7 @@ class StateWithoutNameTest < Test::Unit::TestCase
|
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
124
|
-
class StateWithNameTest < Test
|
126
|
+
class StateWithNameTest < MiniTest::Test
|
125
127
|
def setup
|
126
128
|
@klass = Class.new
|
127
129
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -163,7 +165,7 @@ class StateWithNameTest < Test::Unit::TestCase
|
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
166
|
-
class StateWithNilValueTest < Test
|
168
|
+
class StateWithNilValueTest < MiniTest::Test
|
167
169
|
def setup
|
168
170
|
@klass = Class.new
|
169
171
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -197,7 +199,7 @@ class StateWithNilValueTest < Test::Unit::TestCase
|
|
197
199
|
end
|
198
200
|
end
|
199
201
|
|
200
|
-
class StateWithSymbolicValueTest < Test
|
202
|
+
class StateWithSymbolicValueTest < MiniTest::Test
|
201
203
|
def setup
|
202
204
|
@klass = Class.new
|
203
205
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -228,7 +230,7 @@ class StateWithSymbolicValueTest < Test::Unit::TestCase
|
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
231
|
-
class StateWithIntegerValueTest < Test
|
233
|
+
class StateWithIntegerValueTest < MiniTest::Test
|
232
234
|
def setup
|
233
235
|
@klass = Class.new
|
234
236
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -259,7 +261,7 @@ class StateWithIntegerValueTest < Test::Unit::TestCase
|
|
259
261
|
end
|
260
262
|
end
|
261
263
|
|
262
|
-
class StateWithLambdaValueTest < Test
|
264
|
+
class StateWithLambdaValueTest < MiniTest::Test
|
263
265
|
def setup
|
264
266
|
@klass = Class.new
|
265
267
|
@args = nil
|
@@ -295,7 +297,7 @@ class StateWithLambdaValueTest < Test::Unit::TestCase
|
|
295
297
|
end
|
296
298
|
end
|
297
299
|
|
298
|
-
class StateWithCachedLambdaValueTest < Test
|
300
|
+
class StateWithCachedLambdaValueTest < MiniTest::Test
|
299
301
|
def setup
|
300
302
|
@klass = Class.new
|
301
303
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -323,7 +325,7 @@ class StateWithCachedLambdaValueTest < Test::Unit::TestCase
|
|
323
325
|
end
|
324
326
|
end
|
325
327
|
|
326
|
-
class StateWithoutCachedLambdaValueTest < Test
|
328
|
+
class StateWithoutCachedLambdaValueTest < MiniTest::Test
|
327
329
|
def setup
|
328
330
|
@klass = Class.new
|
329
331
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -337,7 +339,7 @@ class StateWithoutCachedLambdaValueTest < Test::Unit::TestCase
|
|
337
339
|
|
338
340
|
def test_should_evaluate_value_each_time
|
339
341
|
value = @state.value
|
340
|
-
|
342
|
+
refute_same value, @state.value
|
341
343
|
end
|
342
344
|
|
343
345
|
def test_should_not_update_value_index_for_state_collection
|
@@ -347,7 +349,7 @@ class StateWithoutCachedLambdaValueTest < Test::Unit::TestCase
|
|
347
349
|
end
|
348
350
|
end
|
349
351
|
|
350
|
-
class StateWithMatcherTest < Test
|
352
|
+
class StateWithMatcherTest < MiniTest::Test
|
351
353
|
def setup
|
352
354
|
@klass = Class.new
|
353
355
|
@args = nil
|
@@ -364,7 +366,7 @@ class StateWithMatcherTest < Test::Unit::TestCase
|
|
364
366
|
end
|
365
367
|
end
|
366
368
|
|
367
|
-
class StateWithHumanNameTest < Test
|
369
|
+
class StateWithHumanNameTest < MiniTest::Test
|
368
370
|
def setup
|
369
371
|
@klass = Class.new
|
370
372
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -376,7 +378,7 @@ class StateWithHumanNameTest < Test::Unit::TestCase
|
|
376
378
|
end
|
377
379
|
end
|
378
380
|
|
379
|
-
class StateWithDynamicHumanNameTest < Test
|
381
|
+
class StateWithDynamicHumanNameTest < MiniTest::Test
|
380
382
|
def setup
|
381
383
|
@klass = Class.new
|
382
384
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -396,11 +398,11 @@ class StateWithDynamicHumanNameTest < Test::Unit::TestCase
|
|
396
398
|
end
|
397
399
|
|
398
400
|
def test_should_not_cache_value
|
399
|
-
|
401
|
+
refute_same @state.human_name, @state.human_name
|
400
402
|
end
|
401
403
|
end
|
402
404
|
|
403
|
-
class StateInitialTest < Test
|
405
|
+
class StateInitialTest < MiniTest::Test
|
404
406
|
def setup
|
405
407
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
406
408
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :initial => true)
|
@@ -412,7 +414,7 @@ class StateInitialTest < Test::Unit::TestCase
|
|
412
414
|
end
|
413
415
|
end
|
414
416
|
|
415
|
-
class StateNotInitialTest < Test
|
417
|
+
class StateNotInitialTest < MiniTest::Test
|
416
418
|
def setup
|
417
419
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
418
420
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :initial => false)
|
@@ -424,7 +426,7 @@ class StateNotInitialTest < Test::Unit::TestCase
|
|
424
426
|
end
|
425
427
|
end
|
426
428
|
|
427
|
-
class StateFinalTest < Test
|
429
|
+
class StateFinalTest < MiniTest::Test
|
428
430
|
def setup
|
429
431
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
430
432
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -451,7 +453,7 @@ class StateFinalTest < Test::Unit::TestCase
|
|
451
453
|
end
|
452
454
|
end
|
453
455
|
|
454
|
-
class StateNotFinalTest < Test
|
456
|
+
class StateNotFinalTest < MiniTest::Test
|
455
457
|
def setup
|
456
458
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
457
459
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -482,7 +484,7 @@ class StateNotFinalTest < Test::Unit::TestCase
|
|
482
484
|
end
|
483
485
|
end
|
484
486
|
|
485
|
-
class StateWithConflictingHelpersBeforeDefinitionTest < Test
|
487
|
+
class StateWithConflictingHelpersBeforeDefinitionTest < MiniTest::Test
|
486
488
|
def setup
|
487
489
|
require 'stringio'
|
488
490
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -511,7 +513,7 @@ class StateWithConflictingHelpersBeforeDefinitionTest < Test::Unit::TestCase
|
|
511
513
|
end
|
512
514
|
end
|
513
515
|
|
514
|
-
class StateWithConflictingHelpersAfterDefinitionTest < Test
|
516
|
+
class StateWithConflictingHelpersAfterDefinitionTest < MiniTest::Test
|
515
517
|
def setup
|
516
518
|
require 'stringio'
|
517
519
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -549,7 +551,7 @@ class StateWithConflictingHelpersAfterDefinitionTest < Test::Unit::TestCase
|
|
549
551
|
end
|
550
552
|
end
|
551
553
|
|
552
|
-
class StateWithConflictingMachineTest < Test
|
554
|
+
class StateWithConflictingMachineTest < MiniTest::Test
|
553
555
|
def setup
|
554
556
|
require 'stringio'
|
555
557
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -585,7 +587,7 @@ class StateWithConflictingMachineTest < Test::Unit::TestCase
|
|
585
587
|
end
|
586
588
|
end
|
587
589
|
|
588
|
-
class StateWithConflictingMachineNameTest < Test
|
590
|
+
class StateWithConflictingMachineNameTest < MiniTest::Test
|
589
591
|
def setup
|
590
592
|
require 'stringio'
|
591
593
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -604,7 +606,7 @@ class StateWithConflictingMachineNameTest < Test::Unit::TestCase
|
|
604
606
|
end
|
605
607
|
end
|
606
608
|
|
607
|
-
class StateWithNamespaceTest < Test
|
609
|
+
class StateWithNamespaceTest < MiniTest::Test
|
608
610
|
def setup
|
609
611
|
@klass = Class.new
|
610
612
|
@machine = EnumStateMachine::Machine.new(@klass, :namespace => 'alarm')
|
@@ -625,7 +627,7 @@ class StateWithNamespaceTest < Test::Unit::TestCase
|
|
625
627
|
end
|
626
628
|
end
|
627
629
|
|
628
|
-
class StateAfterBeingCopiedTest < Test
|
630
|
+
class StateAfterBeingCopiedTest < MiniTest::Test
|
629
631
|
def setup
|
630
632
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
631
633
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -639,11 +641,11 @@ class StateAfterBeingCopiedTest < Test::Unit::TestCase
|
|
639
641
|
copied_state_context = nil
|
640
642
|
@copied_state.context { copied_state_context = self }
|
641
643
|
|
642
|
-
|
644
|
+
refute_same state_context, copied_state_context
|
643
645
|
end
|
644
646
|
end
|
645
647
|
|
646
|
-
class StateWithContextTest < Test
|
648
|
+
class StateWithContextTest < MiniTest::Test
|
647
649
|
def setup
|
648
650
|
@klass = Class.new
|
649
651
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -677,7 +679,7 @@ class StateWithContextTest < Test::Unit::TestCase
|
|
677
679
|
end
|
678
680
|
|
679
681
|
def test_should_include_new_module_in_owner_class
|
680
|
-
|
682
|
+
refute_equal @ancestors, @klass.ancestors
|
681
683
|
assert_equal [@context], @klass.ancestors - @ancestors
|
682
684
|
end
|
683
685
|
|
@@ -690,8 +692,8 @@ class StateWithContextTest < Test::Unit::TestCase
|
|
690
692
|
end
|
691
693
|
|
692
694
|
def test_should_not_use_context_methods_as_owner_class_methods
|
693
|
-
|
694
|
-
|
695
|
+
refute_equal @speed_method, @state.context_methods[:speed]
|
696
|
+
refute_equal @rpm_method, @state.context_methods[:rpm]
|
695
697
|
end
|
696
698
|
|
697
699
|
def test_should_use_context_methods_as_aliased_owner_class_methods
|
@@ -700,7 +702,7 @@ class StateWithContextTest < Test::Unit::TestCase
|
|
700
702
|
end
|
701
703
|
end
|
702
704
|
|
703
|
-
class StateWithMultipleContextsTest < Test
|
705
|
+
class StateWithMultipleContextsTest < MiniTest::Test
|
704
706
|
def setup
|
705
707
|
@klass = Class.new
|
706
708
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -732,7 +734,7 @@ class StateWithMultipleContextsTest < Test::Unit::TestCase
|
|
732
734
|
end
|
733
735
|
|
734
736
|
def test_should_include_new_module_in_owner_class
|
735
|
-
|
737
|
+
refute_equal @ancestors, @klass.ancestors
|
736
738
|
assert_equal [@context], @klass.ancestors - @ancestors
|
737
739
|
end
|
738
740
|
|
@@ -745,8 +747,8 @@ class StateWithMultipleContextsTest < Test::Unit::TestCase
|
|
745
747
|
end
|
746
748
|
|
747
749
|
def test_should_not_use_context_methods_as_owner_class_methods
|
748
|
-
|
749
|
-
|
750
|
+
refute_equal @speed_method, @state.context_methods[:speed]
|
751
|
+
refute_equal @rpm_method, @state.context_methods[:rpm]
|
750
752
|
end
|
751
753
|
|
752
754
|
def test_should_use_context_methods_as_aliased_owner_class_methods
|
@@ -755,7 +757,7 @@ class StateWithMultipleContextsTest < Test::Unit::TestCase
|
|
755
757
|
end
|
756
758
|
end
|
757
759
|
|
758
|
-
class StateWithExistingContextMethodTest < Test
|
760
|
+
class StateWithExistingContextMethodTest < MiniTest::Test
|
759
761
|
def setup
|
760
762
|
@klass = Class.new do
|
761
763
|
def speed
|
@@ -778,7 +780,7 @@ class StateWithExistingContextMethodTest < Test::Unit::TestCase
|
|
778
780
|
end
|
779
781
|
end
|
780
782
|
|
781
|
-
class StateWithRedefinedContextMethodTest < Test
|
783
|
+
class StateWithRedefinedContextMethodTest < MiniTest::Test
|
782
784
|
def setup
|
783
785
|
@klass = Class.new
|
784
786
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -818,7 +820,7 @@ class StateWithRedefinedContextMethodTest < Test::Unit::TestCase
|
|
818
820
|
end
|
819
821
|
end
|
820
822
|
|
821
|
-
class StateWithInvalidMethodCallTest < Test
|
823
|
+
class StateWithInvalidMethodCallTest < MiniTest::Test
|
822
824
|
def setup
|
823
825
|
@klass = Class.new
|
824
826
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -838,7 +840,7 @@ class StateWithInvalidMethodCallTest < Test::Unit::TestCase
|
|
838
840
|
end
|
839
841
|
end
|
840
842
|
|
841
|
-
class StateWithValidMethodCallForDifferentStateTest < Test
|
843
|
+
class StateWithValidMethodCallForDifferentStateTest < MiniTest::Test
|
842
844
|
def setup
|
843
845
|
@klass = Class.new
|
844
846
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -858,7 +860,7 @@ class StateWithValidMethodCallForDifferentStateTest < Test::Unit::TestCase
|
|
858
860
|
end
|
859
861
|
|
860
862
|
def test_should_raise_invalid_context_on_no_method_error
|
861
|
-
exception =
|
863
|
+
exception = assert_raises(EnumStateMachine::InvalidContext) do
|
862
864
|
@state.call(@object, :speed, :method_missing => lambda { raise NoMethodError.new('Invalid', :speed, [])})
|
863
865
|
end
|
864
866
|
assert_equal @object, exception.object
|
@@ -866,19 +868,19 @@ class StateWithValidMethodCallForDifferentStateTest < Test::Unit::TestCase
|
|
866
868
|
end
|
867
869
|
|
868
870
|
def test_should_raise_original_error_on_no_method_error_with_different_arguments
|
869
|
-
|
871
|
+
assert_raises(NoMethodError) do
|
870
872
|
@state.call(@object, :speed, :method_missing => lambda { raise NoMethodError.new('Invalid', :speed, [1])})
|
871
873
|
end
|
872
874
|
end
|
873
875
|
|
874
876
|
def test_should_raise_original_error_on_no_method_error_for_different_method
|
875
|
-
|
877
|
+
assert_raises(NoMethodError) do
|
876
878
|
@state.call(@object, :speed, :method_missing => lambda { raise NoMethodError.new('Invalid', :rpm, [])})
|
877
879
|
end
|
878
880
|
end
|
879
881
|
end
|
880
882
|
|
881
|
-
class StateWithValidMethodCallForCurrentStateTest < Test
|
883
|
+
class StateWithValidMethodCallForCurrentStateTest < MiniTest::Test
|
882
884
|
def setup
|
883
885
|
@klass = Class.new
|
884
886
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :idling)
|
@@ -911,7 +913,7 @@ class StateWithValidMethodCallForCurrentStateTest < Test::Unit::TestCase
|
|
911
913
|
end
|
912
914
|
|
913
915
|
if RUBY_VERSION > '1.8.7'
|
914
|
-
class StateWithValidInheritedMethodCallForCurrentStateTest < Test
|
916
|
+
class StateWithValidInheritedMethodCallForCurrentStateTest < MiniTest::Test
|
915
917
|
def setup
|
916
918
|
@superclass = Class.new do
|
917
919
|
def speed(arg = nil)
|
@@ -955,7 +957,7 @@ begin
|
|
955
957
|
# Load library
|
956
958
|
require 'graphviz'
|
957
959
|
|
958
|
-
class StateDrawingTest < Test
|
960
|
+
class StateDrawingTest < MiniTest::Test
|
959
961
|
def setup
|
960
962
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
961
963
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :value => 1)
|
@@ -985,7 +987,7 @@ begin
|
|
985
987
|
end
|
986
988
|
end
|
987
989
|
|
988
|
-
class StateDrawingInitialTest < Test
|
990
|
+
class StateDrawingInitialTest < MiniTest::Test
|
989
991
|
def setup
|
990
992
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
991
993
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :initial => true)
|
@@ -1008,7 +1010,7 @@ begin
|
|
1008
1010
|
end
|
1009
1011
|
end
|
1010
1012
|
|
1011
|
-
class StateDrawingNilNameTest < Test
|
1013
|
+
class StateDrawingNilNameTest < MiniTest::Test
|
1012
1014
|
def setup
|
1013
1015
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
1014
1016
|
@machine.states << @state = EnumStateMachine::State.new(@machine, nil)
|
@@ -1019,7 +1021,7 @@ begin
|
|
1019
1021
|
end
|
1020
1022
|
|
1021
1023
|
def test_should_have_a_node
|
1022
|
-
|
1024
|
+
refute_nil @node
|
1023
1025
|
end
|
1024
1026
|
|
1025
1027
|
def test_should_use_description_as_label
|
@@ -1027,7 +1029,7 @@ begin
|
|
1027
1029
|
end
|
1028
1030
|
end
|
1029
1031
|
|
1030
|
-
class StateDrawingLambdaValueTest < Test
|
1032
|
+
class StateDrawingLambdaValueTest < MiniTest::Test
|
1031
1033
|
def setup
|
1032
1034
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
1033
1035
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :value => lambda {})
|
@@ -1038,7 +1040,7 @@ begin
|
|
1038
1040
|
end
|
1039
1041
|
|
1040
1042
|
def test_should_have_a_node
|
1041
|
-
|
1043
|
+
refute_nil @node
|
1042
1044
|
end
|
1043
1045
|
|
1044
1046
|
def test_should_use_description_as_label
|
@@ -1046,7 +1048,7 @@ begin
|
|
1046
1048
|
end
|
1047
1049
|
end
|
1048
1050
|
|
1049
|
-
class StateDrawingNonFinalTest < Test
|
1051
|
+
class StateDrawingNonFinalTest < MiniTest::Test
|
1050
1052
|
def setup
|
1051
1053
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
1052
1054
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -1064,7 +1066,7 @@ begin
|
|
1064
1066
|
end
|
1065
1067
|
end
|
1066
1068
|
|
1067
|
-
class StateDrawingFinalTest < Test
|
1069
|
+
class StateDrawingFinalTest < MiniTest::Test
|
1068
1070
|
def setup
|
1069
1071
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
1070
1072
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked)
|
@@ -1079,7 +1081,7 @@ begin
|
|
1079
1081
|
end
|
1080
1082
|
end
|
1081
1083
|
|
1082
|
-
class StateDrawingWithHumanNameTest < Test
|
1084
|
+
class StateDrawingWithHumanNameTest < MiniTest::Test
|
1083
1085
|
def setup
|
1084
1086
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
1085
1087
|
@machine.states << @state = EnumStateMachine::State.new(@machine, :parked, :human_name => 'Parked')
|