enum_state_machine 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/test/unit/error_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class ErrorByDefaultTest < Test
|
3
|
+
class ErrorByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
6
6
|
@collection = EnumStateMachine::NodeCollection.new(@machine)
|
@@ -20,24 +20,26 @@ class ErrorByDefaultTest < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
class ErrorWithMessageTest < Test
|
23
|
+
class ErrorWithMessageTest < MiniTest::Test
|
24
24
|
def setup
|
25
25
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
26
26
|
@collection = EnumStateMachine::NodeCollection.new(@machine)
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_should_raise_exception_if_invalid_option_specified
|
30
|
-
exception =
|
30
|
+
exception = assert_raises(ArgumentError) {
|
31
|
+
EnumStateMachine::NodeCollection.new(@machine, :invalid => true)
|
32
|
+
}
|
31
33
|
assert_equal 'Invalid key(s): invalid', exception.message
|
32
34
|
end
|
33
35
|
|
34
36
|
def test_should_raise_exception_on_lookup_if_invalid_index_specified
|
35
|
-
exception =
|
37
|
+
exception = assert_raises(ArgumentError) { @collection[:something, :invalid] }
|
36
38
|
assert_equal 'Invalid index: :invalid', exception.message
|
37
39
|
end
|
38
40
|
|
39
41
|
def test_should_raise_exception_on_fetch_if_invalid_index_specified
|
40
|
-
exception =
|
42
|
+
exception = assert_raises(ArgumentError) { @collection.fetch(:something, :invalid) }
|
41
43
|
assert_equal 'Invalid index: :invalid', exception.message
|
42
44
|
end
|
43
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EvalHelpersBaseTest < Test
|
3
|
+
class EvalHelpersBaseTest < MiniTest::Test
|
4
4
|
include EnumStateMachine::EvalHelpers
|
5
5
|
|
6
6
|
def default_test
|
@@ -13,7 +13,7 @@ class EvalHelpersTest < EvalHelpersBaseTest
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_raise_exception_if_method_is_not_symbol_string_or_proc
|
16
|
-
exception =
|
16
|
+
exception = assert_raises(ArgumentError) { evaluate_method(@object, 1) }
|
17
17
|
assert_match(/Methods must/, exception.message)
|
18
18
|
end
|
19
19
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EventCollectionByDefaultTest < Test
|
3
|
+
class EventCollectionByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@klass = Class.new
|
6
6
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -25,7 +25,7 @@ class EventCollectionByDefaultTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
class EventCollectionTest < Test
|
28
|
+
class EventCollectionTest < MiniTest::Test
|
29
29
|
def setup
|
30
30
|
machine = EnumStateMachine::Machine.new(Class.new, :namespace => 'alarm')
|
31
31
|
@events = EnumStateMachine::EventCollection.new(machine)
|
@@ -55,7 +55,7 @@ class EventCollectionTest < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
class EventStringCollectionTest < Test
|
58
|
+
class EventStringCollectionTest < MiniTest::Test
|
59
59
|
def setup
|
60
60
|
machine = EnumStateMachine::Machine.new(Class.new, :namespace => 'alarm')
|
61
61
|
@events = EnumStateMachine::EventCollection.new(machine)
|
@@ -85,7 +85,7 @@ class EventStringCollectionTest < Test::Unit::TestCase
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
class EventCollectionWithEventsWithTransitionsTest < Test
|
88
|
+
class EventCollectionWithEventsWithTransitionsTest < MiniTest::Test
|
89
89
|
def setup
|
90
90
|
@klass = Class.new
|
91
91
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -160,7 +160,7 @@ class EventCollectionWithEventsWithTransitionsTest < Test::Unit::TestCase
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
class EventCollectionWithMultipleEventsTest < Test
|
163
|
+
class EventCollectionWithMultipleEventsTest < MiniTest::Test
|
164
164
|
def setup
|
165
165
|
@klass = Class.new
|
166
166
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -185,7 +185,7 @@ class EventCollectionWithMultipleEventsTest < Test::Unit::TestCase
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
-
class EventCollectionWithoutMachineActionTest < Test
|
188
|
+
class EventCollectionWithoutMachineActionTest < MiniTest::Test
|
189
189
|
def setup
|
190
190
|
@klass = Class.new
|
191
191
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -201,7 +201,7 @@ class EventCollectionWithoutMachineActionTest < Test::Unit::TestCase
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
class EventCollectionAttributeWithMachineActionTest < Test
|
204
|
+
class EventCollectionAttributeWithMachineActionTest < MiniTest::Test
|
205
205
|
def setup
|
206
206
|
@klass = Class.new do
|
207
207
|
def save
|
@@ -262,7 +262,7 @@ class EventCollectionAttributeWithMachineActionTest < Test::Unit::TestCase
|
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
|
-
class EventCollectionAttributeWithNamespacedMachineTest < Test
|
265
|
+
class EventCollectionAttributeWithNamespacedMachineTest < MiniTest::Test
|
266
266
|
def setup
|
267
267
|
@klass = Class.new do
|
268
268
|
def save
|
@@ -297,7 +297,7 @@ class EventCollectionAttributeWithNamespacedMachineTest < Test::Unit::TestCase
|
|
297
297
|
end
|
298
298
|
end
|
299
299
|
|
300
|
-
class EventCollectionWithValidationsTest < Test
|
300
|
+
class EventCollectionWithValidationsTest < MiniTest::Test
|
301
301
|
def setup
|
302
302
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
303
303
|
include EnumStateMachine::Integrations::Base
|
@@ -367,7 +367,7 @@ class EventCollectionWithValidationsTest < Test::Unit::TestCase
|
|
367
367
|
end
|
368
368
|
end
|
369
369
|
|
370
|
-
class EventCollectionWithCustomMachineAttributeTest < Test
|
370
|
+
class EventCollectionWithCustomMachineAttributeTest < MiniTest::Test
|
371
371
|
def setup
|
372
372
|
@klass = Class.new do
|
373
373
|
def save
|
data/test/unit/event_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EventByDefaultTest < Test
|
3
|
+
class EventByDefaultTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@klass = Class.new
|
6
6
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -58,7 +58,7 @@ class EventByDefaultTest < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
class EventTest < Test
|
61
|
+
class EventTest < MiniTest::Test
|
62
62
|
def setup
|
63
63
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
64
64
|
@machine.events << @event = EnumStateMachine::Event.new(@machine, :ignite)
|
@@ -91,7 +91,7 @@ class EventTest < Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
class EventWithHumanNameTest < Test
|
94
|
+
class EventWithHumanNameTest < MiniTest::Test
|
95
95
|
def setup
|
96
96
|
@klass = Class.new
|
97
97
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -103,7 +103,7 @@ class EventWithHumanNameTest < Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
class EventWithDynamicHumanNameTest < Test
|
106
|
+
class EventWithDynamicHumanNameTest < MiniTest::Test
|
107
107
|
def setup
|
108
108
|
@klass = Class.new
|
109
109
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -123,11 +123,11 @@ class EventWithDynamicHumanNameTest < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_should_not_cache_value
|
126
|
-
|
126
|
+
refute_same @event.human_name, @event.human_name
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
class EventWithConflictingHelpersBeforeDefinitionTest < Test
|
130
|
+
class EventWithConflictingHelpersBeforeDefinitionTest < MiniTest::Test
|
131
131
|
def setup
|
132
132
|
require 'stringio'
|
133
133
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -184,7 +184,7 @@ class EventWithConflictingHelpersBeforeDefinitionTest < Test::Unit::TestCase
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
class EventWithConflictingHelpersAfterDefinitionTest < Test
|
187
|
+
class EventWithConflictingHelpersAfterDefinitionTest < MiniTest::Test
|
188
188
|
def setup
|
189
189
|
require 'stringio'
|
190
190
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -249,7 +249,7 @@ class EventWithConflictingHelpersAfterDefinitionTest < Test::Unit::TestCase
|
|
249
249
|
assert_equal false, @object.can_ignite?
|
250
250
|
assert_equal nil, @object.ignite_transition
|
251
251
|
assert_equal false, @object.ignite
|
252
|
-
|
252
|
+
assert_raises(EnumStateMachine::InvalidTransition) { @object.ignite! }
|
253
253
|
end
|
254
254
|
|
255
255
|
def test_should_not_output_warning
|
@@ -261,7 +261,7 @@ class EventWithConflictingHelpersAfterDefinitionTest < Test::Unit::TestCase
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
-
class EventWithConflictingMachineTest < Test
|
264
|
+
class EventWithConflictingMachineTest < MiniTest::Test
|
265
265
|
def setup
|
266
266
|
require 'stringio'
|
267
267
|
@original_stderr, $stderr = $stderr, StringIO.new
|
@@ -308,7 +308,7 @@ class EventWithConflictingMachineTest < Test::Unit::TestCase
|
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
311
|
-
class EventWithNamespaceTest < Test
|
311
|
+
class EventWithNamespaceTest < MiniTest::Test
|
312
312
|
def setup
|
313
313
|
@klass = Class.new
|
314
314
|
@machine = EnumStateMachine::Machine.new(@klass, :namespace => 'alarm')
|
@@ -341,7 +341,7 @@ class EventWithNamespaceTest < Test::Unit::TestCase
|
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
class EventContextTest < Test
|
344
|
+
class EventContextTest < MiniTest::Test
|
345
345
|
def setup
|
346
346
|
@klass = Class.new
|
347
347
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -355,7 +355,7 @@ class EventContextTest < Test::Unit::TestCase
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
-
class EventTransitionsTest < Test
|
358
|
+
class EventTransitionsTest < MiniTest::Test
|
359
359
|
def setup
|
360
360
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
361
361
|
@machine.events << @event = EnumStateMachine::Event.new(@machine, :ignite)
|
@@ -366,7 +366,7 @@ class EventTransitionsTest < Test::Unit::TestCase
|
|
366
366
|
end
|
367
367
|
|
368
368
|
def test_should_not_allow_on_option
|
369
|
-
exception =
|
369
|
+
exception = assert_raises(ArgumentError) {@event.transition(:on => :ignite)}
|
370
370
|
assert_equal 'Invalid key(s): on', exception.message
|
371
371
|
end
|
372
372
|
|
@@ -377,7 +377,7 @@ class EventTransitionsTest < Test::Unit::TestCase
|
|
377
377
|
end
|
378
378
|
|
379
379
|
def test_should_not_allow_except_on_option
|
380
|
-
exception =
|
380
|
+
exception = assert_raises(ArgumentError) {@event.transition(:except_on => :ignite)}
|
381
381
|
assert_equal 'Invalid key(s): except_on', exception.message
|
382
382
|
end
|
383
383
|
|
@@ -415,7 +415,7 @@ class EventTransitionsTest < Test::Unit::TestCase
|
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
418
|
-
class EventAfterBeingCopiedTest < Test
|
418
|
+
class EventAfterBeingCopiedTest < MiniTest::Test
|
419
419
|
def setup
|
420
420
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
421
421
|
@machine.events << @event = EnumStateMachine::Event.new(@machine, :ignite)
|
@@ -423,15 +423,15 @@ class EventAfterBeingCopiedTest < Test::Unit::TestCase
|
|
423
423
|
end
|
424
424
|
|
425
425
|
def test_should_not_have_the_same_collection_of_branches
|
426
|
-
|
426
|
+
refute_same @event.branches, @copied_event.branches
|
427
427
|
end
|
428
428
|
|
429
429
|
def test_should_not_have_the_same_collection_of_known_states
|
430
|
-
|
430
|
+
refute_same @event.known_states, @copied_event.known_states
|
431
431
|
end
|
432
432
|
end
|
433
433
|
|
434
|
-
class EventWithoutTransitionsTest < Test
|
434
|
+
class EventWithoutTransitionsTest < MiniTest::Test
|
435
435
|
def setup
|
436
436
|
@klass = Class.new
|
437
437
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -457,7 +457,7 @@ class EventWithoutTransitionsTest < Test::Unit::TestCase
|
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
460
|
-
class EventWithTransitionsTest < Test
|
460
|
+
class EventWithTransitionsTest < MiniTest::Test
|
461
461
|
def setup
|
462
462
|
@klass = Class.new
|
463
463
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -487,7 +487,7 @@ class EventWithTransitionsTest < Test::Unit::TestCase
|
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
490
|
-
class EventWithoutMatchingTransitionsTest < Test
|
490
|
+
class EventWithoutMatchingTransitionsTest < MiniTest::Test
|
491
491
|
def setup
|
492
492
|
@klass = Class.new
|
493
493
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -513,7 +513,7 @@ class EventWithoutMatchingTransitionsTest < Test::Unit::TestCase
|
|
513
513
|
end
|
514
514
|
|
515
515
|
def test_should_have_a_transition_with_custom_from_state
|
516
|
-
|
516
|
+
refute_nil @event.transition_for(@object, :from => :parked)
|
517
517
|
end
|
518
518
|
|
519
519
|
def test_should_not_fire
|
@@ -526,7 +526,7 @@ class EventWithoutMatchingTransitionsTest < Test::Unit::TestCase
|
|
526
526
|
end
|
527
527
|
end
|
528
528
|
|
529
|
-
class EventWithMatchingDisabledTransitionsTest < Test
|
529
|
+
class EventWithMatchingDisabledTransitionsTest < MiniTest::Test
|
530
530
|
def setup
|
531
531
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
532
532
|
include EnumStateMachine::Integrations::Base
|
@@ -567,7 +567,7 @@ class EventWithMatchingDisabledTransitionsTest < Test::Unit::TestCase
|
|
567
567
|
end
|
568
568
|
|
569
569
|
def test_should_have_a_transition_with_disabled_guards
|
570
|
-
|
570
|
+
refute_nil @event.transition_for(@object, :guard => false)
|
571
571
|
end
|
572
572
|
|
573
573
|
def test_should_not_fire
|
@@ -624,7 +624,7 @@ class EventWithMatchingDisabledTransitionsTest < Test::Unit::TestCase
|
|
624
624
|
|
625
625
|
object, transition = callback_args
|
626
626
|
assert_equal @object, object
|
627
|
-
|
627
|
+
refute_nil transition
|
628
628
|
assert_equal @object, transition.object
|
629
629
|
assert_equal @machine, transition.machine
|
630
630
|
assert_equal :ignite, transition.event
|
@@ -637,7 +637,7 @@ class EventWithMatchingDisabledTransitionsTest < Test::Unit::TestCase
|
|
637
637
|
end
|
638
638
|
end
|
639
639
|
|
640
|
-
class EventWithMatchingEnabledTransitionsTest < Test
|
640
|
+
class EventWithMatchingEnabledTransitionsTest < MiniTest::Test
|
641
641
|
def setup
|
642
642
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
643
643
|
include EnumStateMachine::Integrations::Base
|
@@ -671,7 +671,7 @@ class EventWithMatchingEnabledTransitionsTest < Test::Unit::TestCase
|
|
671
671
|
|
672
672
|
def test_should_have_a_transition
|
673
673
|
transition = @event.transition_for(@object)
|
674
|
-
|
674
|
+
refute_nil transition
|
675
675
|
assert_equal 'parked', transition.from
|
676
676
|
assert_equal 'idling', transition.to
|
677
677
|
assert_equal :ignite, transition.event
|
@@ -708,7 +708,7 @@ class EventWithMatchingEnabledTransitionsTest < Test::Unit::TestCase
|
|
708
708
|
end
|
709
709
|
end
|
710
710
|
|
711
|
-
class EventWithTransitionWithoutToStateTest < Test
|
711
|
+
class EventWithTransitionWithoutToStateTest < MiniTest::Test
|
712
712
|
def setup
|
713
713
|
@klass = Class.new
|
714
714
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -727,7 +727,7 @@ class EventWithTransitionWithoutToStateTest < Test::Unit::TestCase
|
|
727
727
|
|
728
728
|
def test_should_have_a_transition
|
729
729
|
transition = @event.transition_for(@object)
|
730
|
-
|
730
|
+
refute_nil transition
|
731
731
|
assert_equal 'parked', transition.from
|
732
732
|
assert_equal 'parked', transition.to
|
733
733
|
assert_equal :park, transition.event
|
@@ -743,7 +743,7 @@ class EventWithTransitionWithoutToStateTest < Test::Unit::TestCase
|
|
743
743
|
end
|
744
744
|
end
|
745
745
|
|
746
|
-
class EventWithTransitionWithNilToStateTest < Test
|
746
|
+
class EventWithTransitionWithNilToStateTest < MiniTest::Test
|
747
747
|
def setup
|
748
748
|
@klass = Class.new
|
749
749
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -762,7 +762,7 @@ class EventWithTransitionWithNilToStateTest < Test::Unit::TestCase
|
|
762
762
|
|
763
763
|
def test_should_have_a_transition
|
764
764
|
transition = @event.transition_for(@object)
|
765
|
-
|
765
|
+
refute_nil transition
|
766
766
|
assert_equal 'idling', transition.from
|
767
767
|
assert_equal nil, transition.to
|
768
768
|
assert_equal :park, transition.event
|
@@ -778,7 +778,7 @@ class EventWithTransitionWithNilToStateTest < Test::Unit::TestCase
|
|
778
778
|
end
|
779
779
|
end
|
780
780
|
|
781
|
-
class EventWithTransitionWithLoopbackStateTest < Test
|
781
|
+
class EventWithTransitionWithLoopbackStateTest < MiniTest::Test
|
782
782
|
def setup
|
783
783
|
@klass = Class.new
|
784
784
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -797,7 +797,7 @@ class EventWithTransitionWithLoopbackStateTest < Test::Unit::TestCase
|
|
797
797
|
|
798
798
|
def test_should_have_a_transition
|
799
799
|
transition = @event.transition_for(@object)
|
800
|
-
|
800
|
+
refute_nil transition
|
801
801
|
assert_equal 'parked', transition.from
|
802
802
|
assert_equal 'parked', transition.to
|
803
803
|
assert_equal :park, transition.event
|
@@ -813,7 +813,7 @@ class EventWithTransitionWithLoopbackStateTest < Test::Unit::TestCase
|
|
813
813
|
end
|
814
814
|
end
|
815
815
|
|
816
|
-
class EventWithTransitionWithBlacklistedToStateTest < Test
|
816
|
+
class EventWithTransitionWithBlacklistedToStateTest < MiniTest::Test
|
817
817
|
def setup
|
818
818
|
@klass = Class.new
|
819
819
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -832,7 +832,7 @@ class EventWithTransitionWithBlacklistedToStateTest < Test::Unit::TestCase
|
|
832
832
|
|
833
833
|
def test_should_have_a_transition
|
834
834
|
transition = @event.transition_for(@object)
|
835
|
-
|
835
|
+
refute_nil transition
|
836
836
|
assert_equal 'parked', transition.from
|
837
837
|
assert_equal 'first_gear', transition.to
|
838
838
|
assert_equal :ignite, transition.event
|
@@ -843,7 +843,7 @@ class EventWithTransitionWithBlacklistedToStateTest < Test::Unit::TestCase
|
|
843
843
|
@object.state = 'second_gear'
|
844
844
|
|
845
845
|
transition = @event.transition_for(@object)
|
846
|
-
|
846
|
+
refute_nil transition
|
847
847
|
assert_equal 'second_gear', transition.from
|
848
848
|
assert_equal 'second_gear', transition.to
|
849
849
|
assert_equal :ignite, transition.event
|
@@ -852,7 +852,7 @@ class EventWithTransitionWithBlacklistedToStateTest < Test::Unit::TestCase
|
|
852
852
|
def test_should_allow_specific_transition_selection_using_to
|
853
853
|
transition = @event.transition_for(@object, :from => :parked, :to => :second_gear)
|
854
854
|
|
855
|
-
|
855
|
+
refute_nil transition
|
856
856
|
assert_equal 'parked', transition.from
|
857
857
|
assert_equal 'second_gear', transition.to
|
858
858
|
assert_equal :ignite, transition.event
|
@@ -873,7 +873,7 @@ class EventWithTransitionWithBlacklistedToStateTest < Test::Unit::TestCase
|
|
873
873
|
end
|
874
874
|
end
|
875
875
|
|
876
|
-
class EventWithTransitionWithWhitelistedToStateTest < Test
|
876
|
+
class EventWithTransitionWithWhitelistedToStateTest < MiniTest::Test
|
877
877
|
def setup
|
878
878
|
@klass = Class.new
|
879
879
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
@@ -892,7 +892,7 @@ class EventWithTransitionWithWhitelistedToStateTest < Test::Unit::TestCase
|
|
892
892
|
|
893
893
|
def test_should_have_a_transition
|
894
894
|
transition = @event.transition_for(@object)
|
895
|
-
|
895
|
+
refute_nil transition
|
896
896
|
assert_equal 'parked', transition.from
|
897
897
|
assert_equal 'first_gear', transition.to
|
898
898
|
assert_equal :ignite, transition.event
|
@@ -901,7 +901,7 @@ class EventWithTransitionWithWhitelistedToStateTest < Test::Unit::TestCase
|
|
901
901
|
def test_should_allow_specific_transition_selection_using_to
|
902
902
|
transition = @event.transition_for(@object, :from => :parked, :to => :second_gear)
|
903
903
|
|
904
|
-
|
904
|
+
refute_nil transition
|
905
905
|
assert_equal 'parked', transition.from
|
906
906
|
assert_equal 'second_gear', transition.to
|
907
907
|
assert_equal :ignite, transition.event
|
@@ -922,7 +922,7 @@ class EventWithTransitionWithWhitelistedToStateTest < Test::Unit::TestCase
|
|
922
922
|
end
|
923
923
|
end
|
924
924
|
|
925
|
-
class EventWithMultipleTransitionsTest < Test
|
925
|
+
class EventWithMultipleTransitionsTest < MiniTest::Test
|
926
926
|
def setup
|
927
927
|
@klass = Class.new
|
928
928
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -943,7 +943,7 @@ class EventWithMultipleTransitionsTest < Test::Unit::TestCase
|
|
943
943
|
|
944
944
|
def test_should_have_a_transition
|
945
945
|
transition = @event.transition_for(@object)
|
946
|
-
|
946
|
+
refute_nil transition
|
947
947
|
assert_equal 'parked', transition.from
|
948
948
|
assert_equal 'idling', transition.to
|
949
949
|
assert_equal :ignite, transition.event
|
@@ -952,7 +952,7 @@ class EventWithMultipleTransitionsTest < Test::Unit::TestCase
|
|
952
952
|
def test_should_allow_specific_transition_selection_using_from
|
953
953
|
transition = @event.transition_for(@object, :from => :idling)
|
954
954
|
|
955
|
-
|
955
|
+
refute_nil transition
|
956
956
|
assert_equal 'idling', transition.from
|
957
957
|
assert_equal 'idling', transition.to
|
958
958
|
assert_equal :ignite, transition.event
|
@@ -961,14 +961,14 @@ class EventWithMultipleTransitionsTest < Test::Unit::TestCase
|
|
961
961
|
def test_should_allow_specific_transition_selection_using_to
|
962
962
|
transition = @event.transition_for(@object, :from => :parked, :to => :parked)
|
963
963
|
|
964
|
-
|
964
|
+
refute_nil transition
|
965
965
|
assert_equal 'parked', transition.from
|
966
966
|
assert_equal 'parked', transition.to
|
967
967
|
assert_equal :ignite, transition.event
|
968
968
|
end
|
969
969
|
|
970
970
|
def test_should_not_allow_specific_transition_selection_using_on
|
971
|
-
exception =
|
971
|
+
exception = assert_raises(ArgumentError) { @event.transition_for(@object, :on => :park) }
|
972
972
|
assert_equal 'Invalid key(s): on', exception.message
|
973
973
|
end
|
974
974
|
|
@@ -982,7 +982,7 @@ class EventWithMultipleTransitionsTest < Test::Unit::TestCase
|
|
982
982
|
end
|
983
983
|
end
|
984
984
|
|
985
|
-
class EventWithMachineActionTest < Test
|
985
|
+
class EventWithMachineActionTest < MiniTest::Test
|
986
986
|
def setup
|
987
987
|
@klass = Class.new do
|
988
988
|
attr_reader :saved
|
@@ -1013,7 +1013,7 @@ class EventWithMachineActionTest < Test::Unit::TestCase
|
|
1013
1013
|
end
|
1014
1014
|
end
|
1015
1015
|
|
1016
|
-
class EventWithInvalidCurrentStateTest < Test
|
1016
|
+
class EventWithInvalidCurrentStateTest < MiniTest::Test
|
1017
1017
|
def setup
|
1018
1018
|
@klass = Class.new
|
1019
1019
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -1027,22 +1027,22 @@ class EventWithInvalidCurrentStateTest < Test::Unit::TestCase
|
|
1027
1027
|
end
|
1028
1028
|
|
1029
1029
|
def test_should_raise_exception_when_checking_availability
|
1030
|
-
exception =
|
1030
|
+
exception = assert_raises(ArgumentError) { @event.can_fire?(@object) }
|
1031
1031
|
assert_equal '"invalid" is not a known state value', exception.message
|
1032
1032
|
end
|
1033
1033
|
|
1034
1034
|
def test_should_raise_exception_when_finding_transition
|
1035
|
-
exception =
|
1035
|
+
exception = assert_raises(ArgumentError) { @event.transition_for(@object) }
|
1036
1036
|
assert_equal '"invalid" is not a known state value', exception.message
|
1037
1037
|
end
|
1038
1038
|
|
1039
1039
|
def test_should_raise_exception_when_firing
|
1040
|
-
exception =
|
1040
|
+
exception = assert_raises(ArgumentError) { @event.fire(@object) }
|
1041
1041
|
assert_equal '"invalid" is not a known state value', exception.message
|
1042
1042
|
end
|
1043
1043
|
end
|
1044
1044
|
|
1045
|
-
class EventOnFailureTest < Test
|
1045
|
+
class EventOnFailureTest < MiniTest::Test
|
1046
1046
|
def setup
|
1047
1047
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
1048
1048
|
include EnumStateMachine::Integrations::Base
|
@@ -1081,7 +1081,7 @@ class EventOnFailureTest < Test::Unit::TestCase
|
|
1081
1081
|
|
1082
1082
|
object, transition = callback_args
|
1083
1083
|
assert_equal @object, object
|
1084
|
-
|
1084
|
+
refute_nil transition
|
1085
1085
|
assert_equal @object, transition.object
|
1086
1086
|
assert_equal @machine, transition.machine
|
1087
1087
|
assert_equal :ignite, transition.event
|
@@ -1094,7 +1094,7 @@ class EventOnFailureTest < Test::Unit::TestCase
|
|
1094
1094
|
end
|
1095
1095
|
end
|
1096
1096
|
|
1097
|
-
class EventWithMarshallingTest < Test
|
1097
|
+
class EventWithMarshallingTest < MiniTest::Test
|
1098
1098
|
def setup
|
1099
1099
|
@klass = Class.new do
|
1100
1100
|
def save
|
@@ -1143,7 +1143,7 @@ begin
|
|
1143
1143
|
# Load library
|
1144
1144
|
require 'graphviz'
|
1145
1145
|
|
1146
|
-
class EventDrawingTest < Test
|
1146
|
+
class EventDrawingTest < MiniTest::Test
|
1147
1147
|
def setup
|
1148
1148
|
states = [:parked, :idling, :first_gear]
|
1149
1149
|
|
@@ -1170,7 +1170,7 @@ begin
|
|
1170
1170
|
end
|
1171
1171
|
end
|
1172
1172
|
|
1173
|
-
class EventDrawingWithHumanNameTest < Test
|
1173
|
+
class EventDrawingWithHumanNameTest < MiniTest::Test
|
1174
1174
|
def setup
|
1175
1175
|
states = [:parked, :idling]
|
1176
1176
|
|
@@ -1192,5 +1192,6 @@ begin
|
|
1192
1192
|
end
|
1193
1193
|
end
|
1194
1194
|
rescue LoadError
|
1195
|
-
$stderr.puts 'Skipping GraphViz EnumStateMachine::Event tests.
|
1195
|
+
$stderr.puts 'Skipping GraphViz EnumStateMachine::Event tests. ' \
|
1196
|
+
'`gem install ruby-graphviz` >= v0.9.17 and try again.'
|
1196
1197
|
end unless ENV['TRAVIS']
|