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
@@ -1,8 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class TransitionCollectionTest < Test
|
3
|
+
class TransitionCollectionTest < MiniTest::Test
|
4
4
|
def test_should_raise_exception_if_invalid_option_specified
|
5
|
-
exception =
|
5
|
+
exception = assert_raises(ArgumentError) {
|
6
|
+
EnumStateMachine::TransitionCollection.new([], :invalid => true)
|
7
|
+
}
|
6
8
|
assert_equal 'Invalid key(s): invalid', exception.message
|
7
9
|
end
|
8
10
|
|
@@ -15,7 +17,7 @@ class TransitionCollectionTest < Test::Unit::TestCase
|
|
15
17
|
|
16
18
|
@object = @klass.new
|
17
19
|
|
18
|
-
exception =
|
20
|
+
exception = assert_raises(ArgumentError) do
|
19
21
|
EnumStateMachine::TransitionCollection.new([
|
20
22
|
EnumStateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling),
|
21
23
|
EnumStateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
|
@@ -25,7 +27,7 @@ class TransitionCollectionTest < Test::Unit::TestCase
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
class TransitionCollectionByDefaultTest < Test
|
30
|
+
class TransitionCollectionByDefaultTest < MiniTest::Test
|
29
31
|
def setup
|
30
32
|
@transitions = EnumStateMachine::TransitionCollection.new
|
31
33
|
end
|
@@ -47,7 +49,7 @@ class TransitionCollectionByDefaultTest < Test::Unit::TestCase
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
|
-
class TransitionCollectionEmptyWithoutBlockTest < Test
|
52
|
+
class TransitionCollectionEmptyWithoutBlockTest < MiniTest::Test
|
51
53
|
def setup
|
52
54
|
@transitions = EnumStateMachine::TransitionCollection.new
|
53
55
|
@result = @transitions.perform
|
@@ -59,13 +61,13 @@ class TransitionCollectionEmptyWithoutBlockTest < Test::Unit::TestCase
|
|
59
61
|
end
|
60
62
|
|
61
63
|
|
62
|
-
class TransitionCollectionEmptyWithBlockTest < Test
|
64
|
+
class TransitionCollectionEmptyWithBlockTest < MiniTest::Test
|
63
65
|
def setup
|
64
66
|
@transitions = EnumStateMachine::TransitionCollection.new
|
65
67
|
end
|
66
68
|
|
67
69
|
def test_should_raise_exception_if_perform_raises_exception
|
68
|
-
|
70
|
+
assert_raises(ArgumentError) { @transitions.perform { raise ArgumentError } }
|
69
71
|
end
|
70
72
|
|
71
73
|
def test_should_use_block_result_if_non_boolean
|
@@ -81,7 +83,7 @@ class TransitionCollectionEmptyWithBlockTest < Test::Unit::TestCase
|
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
84
|
-
class TransitionCollectionInvalidTest < Test
|
86
|
+
class TransitionCollectionInvalidTest < MiniTest::Test
|
85
87
|
def setup
|
86
88
|
@transitions = EnumStateMachine::TransitionCollection.new([false])
|
87
89
|
end
|
@@ -101,7 +103,7 @@ class TransitionCollectionInvalidTest < Test::Unit::TestCase
|
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
104
|
-
class TransitionCollectionPartialInvalidTest < Test
|
106
|
+
class TransitionCollectionPartialInvalidTest < MiniTest::Test
|
105
107
|
def setup
|
106
108
|
@klass = Class.new do
|
107
109
|
attr_accessor :ran_transaction
|
@@ -169,7 +171,7 @@ class TransitionCollectionPartialInvalidTest < Test::Unit::TestCase
|
|
169
171
|
end
|
170
172
|
end
|
171
173
|
|
172
|
-
class TransitionCollectionValidTest < Test
|
174
|
+
class TransitionCollectionValidTest < MiniTest::Test
|
173
175
|
def setup
|
174
176
|
@klass = Class.new do
|
175
177
|
attr_reader :persisted
|
@@ -225,7 +227,7 @@ class TransitionCollectionValidTest < Test::Unit::TestCase
|
|
225
227
|
end
|
226
228
|
end
|
227
229
|
|
228
|
-
class TransitionCollectionWithoutTransactionsTest < Test
|
230
|
+
class TransitionCollectionWithoutTransactionsTest < MiniTest::Test
|
229
231
|
def setup
|
230
232
|
@klass = Class.new do
|
231
233
|
attr_accessor :ran_transaction
|
@@ -253,7 +255,7 @@ class TransitionCollectionWithoutTransactionsTest < Test::Unit::TestCase
|
|
253
255
|
end
|
254
256
|
end
|
255
257
|
|
256
|
-
class TransitionCollectionWithTransactionsTest < Test
|
258
|
+
class TransitionCollectionWithTransactionsTest < MiniTest::Test
|
257
259
|
def setup
|
258
260
|
@klass = Class.new do
|
259
261
|
attr_accessor :running_transaction, :cancelled_transaction
|
@@ -317,7 +319,7 @@ class TransitionCollectionWithTransactionsTest < Test::Unit::TestCase
|
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
320
|
-
class TransitionCollectionWithEmptyActionsTest < Test
|
322
|
+
class TransitionCollectionWithEmptyActionsTest < MiniTest::Test
|
321
323
|
def setup
|
322
324
|
@klass = Class.new
|
323
325
|
|
@@ -357,7 +359,7 @@ class TransitionCollectionWithEmptyActionsTest < Test::Unit::TestCase
|
|
357
359
|
end
|
358
360
|
end
|
359
361
|
|
360
|
-
class TransitionCollectionWithSkippedActionsTest < Test
|
362
|
+
class TransitionCollectionWithSkippedActionsTest < MiniTest::Test
|
361
363
|
def setup
|
362
364
|
@klass = Class.new do
|
363
365
|
attr_reader :actions
|
@@ -425,7 +427,7 @@ class TransitionCollectionWithSkippedActionsTest < Test::Unit::TestCase
|
|
425
427
|
end
|
426
428
|
end
|
427
429
|
|
428
|
-
class TransitionCollectionWithSkippedActionsAndBlockTest < Test
|
430
|
+
class TransitionCollectionWithSkippedActionsAndBlockTest < MiniTest::Test
|
429
431
|
def setup
|
430
432
|
@klass = Class.new
|
431
433
|
|
@@ -458,7 +460,7 @@ class TransitionCollectionWithSkippedActionsAndBlockTest < Test::Unit::TestCase
|
|
458
460
|
end
|
459
461
|
end
|
460
462
|
|
461
|
-
class TransitionCollectionWithDuplicateActionsTest < Test
|
463
|
+
class TransitionCollectionWithDuplicateActionsTest < MiniTest::Test
|
462
464
|
def setup
|
463
465
|
@klass = Class.new do
|
464
466
|
attr_reader :actions
|
@@ -505,7 +507,7 @@ class TransitionCollectionWithDuplicateActionsTest < Test::Unit::TestCase
|
|
505
507
|
end
|
506
508
|
end
|
507
509
|
|
508
|
-
class TransitionCollectionWithDifferentActionsTest < Test
|
510
|
+
class TransitionCollectionWithDifferentActionsTest < MiniTest::Test
|
509
511
|
def setup
|
510
512
|
@klass = Class.new do
|
511
513
|
attr_reader :actions
|
@@ -680,7 +682,7 @@ class TransitionCollectionWithDifferentActionsTest < Test::Unit::TestCase
|
|
680
682
|
end
|
681
683
|
end
|
682
684
|
|
683
|
-
class TransitionCollectionWithMixedActionsTest < Test
|
685
|
+
class TransitionCollectionWithMixedActionsTest < MiniTest::Test
|
684
686
|
def setup
|
685
687
|
@klass = Class.new do
|
686
688
|
def save
|
@@ -720,7 +722,7 @@ class TransitionCollectionWithMixedActionsTest < Test::Unit::TestCase
|
|
720
722
|
end
|
721
723
|
end
|
722
724
|
|
723
|
-
class TransitionCollectionWithBlockTest < Test
|
725
|
+
class TransitionCollectionWithBlockTest < MiniTest::Test
|
724
726
|
def setup
|
725
727
|
@klass = Class.new do
|
726
728
|
attr_reader :actions
|
@@ -765,7 +767,7 @@ class TransitionCollectionWithBlockTest < Test::Unit::TestCase
|
|
765
767
|
end
|
766
768
|
end
|
767
769
|
|
768
|
-
class TransitionCollectionWithActionFailedTest < Test
|
770
|
+
class TransitionCollectionWithActionFailedTest < MiniTest::Test
|
769
771
|
def setup
|
770
772
|
@klass = Class.new do
|
771
773
|
def save
|
@@ -824,7 +826,7 @@ class TransitionCollectionWithActionFailedTest < Test::Unit::TestCase
|
|
824
826
|
end
|
825
827
|
end
|
826
828
|
|
827
|
-
class TransitionCollectionWithActionErrorTest < Test
|
829
|
+
class TransitionCollectionWithActionErrorTest < MiniTest::Test
|
828
830
|
def setup
|
829
831
|
@klass = Class.new do
|
830
832
|
def save
|
@@ -889,7 +891,7 @@ class TransitionCollectionWithActionErrorTest < Test::Unit::TestCase
|
|
889
891
|
end
|
890
892
|
end
|
891
893
|
|
892
|
-
class TransitionCollectionWithCallbacksTest < Test
|
894
|
+
class TransitionCollectionWithCallbacksTest < MiniTest::Test
|
893
895
|
def setup
|
894
896
|
@klass = Class.new do
|
895
897
|
attr_reader :saved
|
@@ -1023,7 +1025,7 @@ class TransitionCollectionWithCallbacksTest < Test::Unit::TestCase
|
|
1023
1025
|
end
|
1024
1026
|
end
|
1025
1027
|
|
1026
|
-
class TransitionCollectionWithBeforeCallbackHaltTest < Test
|
1028
|
+
class TransitionCollectionWithBeforeCallbackHaltTest < MiniTest::Test
|
1027
1029
|
def setup
|
1028
1030
|
@klass = Class.new do
|
1029
1031
|
attr_reader :saved
|
@@ -1073,7 +1075,7 @@ class TransitionCollectionWithBeforeCallbackHaltTest < Test::Unit::TestCase
|
|
1073
1075
|
end
|
1074
1076
|
end
|
1075
1077
|
|
1076
|
-
class TransitionCollectionWithAfterCallbackHaltTest < Test
|
1078
|
+
class TransitionCollectionWithAfterCallbackHaltTest < MiniTest::Test
|
1077
1079
|
def setup
|
1078
1080
|
@klass = Class.new do
|
1079
1081
|
attr_reader :saved
|
@@ -1119,7 +1121,7 @@ class TransitionCollectionWithAfterCallbackHaltTest < Test::Unit::TestCase
|
|
1119
1121
|
end
|
1120
1122
|
end
|
1121
1123
|
|
1122
|
-
class TransitionCollectionWithSkippedAfterCallbacksTest < Test
|
1124
|
+
class TransitionCollectionWithSkippedAfterCallbacksTest < MiniTest::Test
|
1123
1125
|
def setup
|
1124
1126
|
@klass = Class.new
|
1125
1127
|
|
@@ -1153,7 +1155,7 @@ class TransitionCollectionWithSkippedAfterCallbacksTest < Test::Unit::TestCase
|
|
1153
1155
|
end
|
1154
1156
|
|
1155
1157
|
if EnumStateMachine::Transition.pause_supported?
|
1156
|
-
class TransitionCollectionWithSkippedAfterCallbacksAndAroundCallbacksTest < Test
|
1158
|
+
class TransitionCollectionWithSkippedAfterCallbacksAndAroundCallbacksTest < MiniTest::Test
|
1157
1159
|
def setup
|
1158
1160
|
@klass = Class.new
|
1159
1161
|
|
@@ -1193,7 +1195,7 @@ if EnumStateMachine::Transition.pause_supported?
|
|
1193
1195
|
end
|
1194
1196
|
end
|
1195
1197
|
else
|
1196
|
-
class TransitionCollectionWithSkippedAfterCallbacksAndAroundCallbacksTest < Test
|
1198
|
+
class TransitionCollectionWithSkippedAfterCallbacksAndAroundCallbacksTest < MiniTest::Test
|
1197
1199
|
def setup
|
1198
1200
|
@klass = Class.new
|
1199
1201
|
|
@@ -1212,12 +1214,12 @@ else
|
|
1212
1214
|
end
|
1213
1215
|
|
1214
1216
|
def test_should_raise_exception
|
1215
|
-
|
1217
|
+
assert_raises(ArgumentError) { @transitions.perform }
|
1216
1218
|
end
|
1217
1219
|
end
|
1218
1220
|
end
|
1219
1221
|
|
1220
|
-
class TransitionCollectionWithActionHookBaseTest < Test
|
1222
|
+
class TransitionCollectionWithActionHookBaseTest < MiniTest::Test
|
1221
1223
|
def setup
|
1222
1224
|
@superclass = Class.new do
|
1223
1225
|
def save
|
@@ -1558,7 +1560,7 @@ class TransitionCollectionWithActionHookErrorTest < TransitionCollectionWithActi
|
|
1558
1560
|
end
|
1559
1561
|
end
|
1560
1562
|
|
1561
|
-
class AttributeTransitionCollectionByDefaultTest < Test
|
1563
|
+
class AttributeTransitionCollectionByDefaultTest < MiniTest::Test
|
1562
1564
|
def setup
|
1563
1565
|
@transitions = EnumStateMachine::AttributeTransitionCollection.new
|
1564
1566
|
end
|
@@ -1580,7 +1582,7 @@ class AttributeTransitionCollectionByDefaultTest < Test::Unit::TestCase
|
|
1580
1582
|
end
|
1581
1583
|
end
|
1582
1584
|
|
1583
|
-
class AttributeTransitionCollectionWithEventsTest < Test
|
1585
|
+
class AttributeTransitionCollectionWithEventsTest < MiniTest::Test
|
1584
1586
|
def setup
|
1585
1587
|
@klass = Class.new
|
1586
1588
|
|
@@ -1623,7 +1625,7 @@ class AttributeTransitionCollectionWithEventsTest < Test::Unit::TestCase
|
|
1623
1625
|
end
|
1624
1626
|
end
|
1625
1627
|
|
1626
|
-
class AttributeTransitionCollectionWithEventTransitionsTest < Test
|
1628
|
+
class AttributeTransitionCollectionWithEventTransitionsTest < MiniTest::Test
|
1627
1629
|
def setup
|
1628
1630
|
@klass = Class.new
|
1629
1631
|
|
@@ -1663,7 +1665,7 @@ class AttributeTransitionCollectionWithEventTransitionsTest < Test::Unit::TestCa
|
|
1663
1665
|
end
|
1664
1666
|
end
|
1665
1667
|
|
1666
|
-
class AttributeTransitionCollectionWithActionFailedTest < Test
|
1668
|
+
class AttributeTransitionCollectionWithActionFailedTest < MiniTest::Test
|
1667
1669
|
def setup
|
1668
1670
|
@klass = Class.new
|
1669
1671
|
|
@@ -1706,7 +1708,7 @@ class AttributeTransitionCollectionWithActionFailedTest < Test::Unit::TestCase
|
|
1706
1708
|
end
|
1707
1709
|
end
|
1708
1710
|
|
1709
|
-
class AttributeTransitionCollectionWithActionErrorTest < Test
|
1711
|
+
class AttributeTransitionCollectionWithActionErrorTest < MiniTest::Test
|
1710
1712
|
def setup
|
1711
1713
|
@klass = Class.new
|
1712
1714
|
|
@@ -1746,7 +1748,7 @@ class AttributeTransitionCollectionWithActionErrorTest < Test::Unit::TestCase
|
|
1746
1748
|
end
|
1747
1749
|
end
|
1748
1750
|
|
1749
|
-
class AttributeTransitionCollectionWithCallbacksTest < Test
|
1751
|
+
class AttributeTransitionCollectionWithCallbacksTest < MiniTest::Test
|
1750
1752
|
def setup
|
1751
1753
|
@klass = Class.new
|
1752
1754
|
|
@@ -1813,7 +1815,7 @@ class AttributeTransitionCollectionWithCallbacksTest < Test::Unit::TestCase
|
|
1813
1815
|
end
|
1814
1816
|
end
|
1815
1817
|
|
1816
|
-
class AttributeTransitionCollectionWithBeforeCallbackHaltTest < Test
|
1818
|
+
class AttributeTransitionCollectionWithBeforeCallbackHaltTest < MiniTest::Test
|
1817
1819
|
def setup
|
1818
1820
|
@klass = Class.new
|
1819
1821
|
|
@@ -1845,7 +1847,7 @@ class AttributeTransitionCollectionWithBeforeCallbackHaltTest < Test::Unit::Test
|
|
1845
1847
|
end
|
1846
1848
|
end
|
1847
1849
|
|
1848
|
-
class AttributeTransitionCollectionWithBeforeCallbackErrorTest < Test
|
1850
|
+
class AttributeTransitionCollectionWithBeforeCallbackErrorTest < MiniTest::Test
|
1849
1851
|
def setup
|
1850
1852
|
@klass = Class.new
|
1851
1853
|
|
@@ -1873,7 +1875,7 @@ class AttributeTransitionCollectionWithBeforeCallbackErrorTest < Test::Unit::Tes
|
|
1873
1875
|
end
|
1874
1876
|
end
|
1875
1877
|
|
1876
|
-
class AttributeTransitionCollectionWithAroundCallbackBeforeYieldHaltTest < Test
|
1878
|
+
class AttributeTransitionCollectionWithAroundCallbackBeforeYieldHaltTest < MiniTest::Test
|
1877
1879
|
def setup
|
1878
1880
|
@klass = Class.new
|
1879
1881
|
|
@@ -1905,7 +1907,7 @@ class AttributeTransitionCollectionWithAroundCallbackBeforeYieldHaltTest < Test:
|
|
1905
1907
|
end
|
1906
1908
|
end
|
1907
1909
|
|
1908
|
-
class AttributeTransitionCollectionWithAroundAfterYieldCallbackErrorTest < Test
|
1910
|
+
class AttributeTransitionCollectionWithAroundAfterYieldCallbackErrorTest < MiniTest::Test
|
1909
1911
|
def setup
|
1910
1912
|
@klass = Class.new
|
1911
1913
|
|
@@ -1933,7 +1935,7 @@ class AttributeTransitionCollectionWithAroundAfterYieldCallbackErrorTest < Test:
|
|
1933
1935
|
end
|
1934
1936
|
end
|
1935
1937
|
|
1936
|
-
class AttributeTransitionCollectionWithSkippedAfterCallbacksTest < Test
|
1938
|
+
class AttributeTransitionCollectionWithSkippedAfterCallbacksTest < MiniTest::Test
|
1937
1939
|
def setup
|
1938
1940
|
@klass = Class.new
|
1939
1941
|
|
@@ -1974,7 +1976,7 @@ class AttributeTransitionCollectionWithSkippedAfterCallbacksTest < Test::Unit::T
|
|
1974
1976
|
end
|
1975
1977
|
end
|
1976
1978
|
|
1977
|
-
class AttributeTransitionCollectionWithAfterCallbackHaltTest < Test
|
1979
|
+
class AttributeTransitionCollectionWithAfterCallbackHaltTest < MiniTest::Test
|
1978
1980
|
def setup
|
1979
1981
|
@klass = Class.new
|
1980
1982
|
|
@@ -2006,7 +2008,7 @@ class AttributeTransitionCollectionWithAfterCallbackHaltTest < Test::Unit::TestC
|
|
2006
2008
|
end
|
2007
2009
|
end
|
2008
2010
|
|
2009
|
-
class AttributeTransitionCollectionWithAfterCallbackErrorTest < Test
|
2011
|
+
class AttributeTransitionCollectionWithAfterCallbackErrorTest < MiniTest::Test
|
2010
2012
|
def setup
|
2011
2013
|
@klass = Class.new
|
2012
2014
|
|
@@ -2034,7 +2036,7 @@ class AttributeTransitionCollectionWithAfterCallbackErrorTest < Test::Unit::Test
|
|
2034
2036
|
end
|
2035
2037
|
end
|
2036
2038
|
|
2037
|
-
class AttributeTransitionCollectionWithAroundCallbackAfterYieldHaltTest < Test
|
2039
|
+
class AttributeTransitionCollectionWithAroundCallbackAfterYieldHaltTest < MiniTest::Test
|
2038
2040
|
def setup
|
2039
2041
|
@klass = Class.new
|
2040
2042
|
|
@@ -2066,7 +2068,7 @@ class AttributeTransitionCollectionWithAroundCallbackAfterYieldHaltTest < Test::
|
|
2066
2068
|
end
|
2067
2069
|
end
|
2068
2070
|
|
2069
|
-
class AttributeTransitionCollectionWithAroundCallbackAfterYieldErrorTest < Test
|
2071
|
+
class AttributeTransitionCollectionWithAroundCallbackAfterYieldErrorTest < MiniTest::Test
|
2070
2072
|
def setup
|
2071
2073
|
@klass = Class.new
|
2072
2074
|
|
@@ -2094,7 +2096,7 @@ class AttributeTransitionCollectionWithAroundCallbackAfterYieldErrorTest < Test:
|
|
2094
2096
|
end
|
2095
2097
|
end
|
2096
2098
|
|
2097
|
-
class AttributeTransitionCollectionMarshallingTest < Test
|
2099
|
+
class AttributeTransitionCollectionMarshallingTest < MiniTest::Test
|
2098
2100
|
def setup
|
2099
2101
|
@klass = Class.new
|
2100
2102
|
self.class.const_set('Example', @klass)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class TransitionTest < Test
|
3
|
+
class TransitionTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@klass = Class.new
|
6
6
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -95,7 +95,7 @@ class TransitionTest < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
class TransitionWithInvalidNodesTest < Test
|
98
|
+
class TransitionWithInvalidNodesTest < MiniTest::Test
|
99
99
|
def setup
|
100
100
|
@klass = Class.new
|
101
101
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -107,23 +107,31 @@ class TransitionWithInvalidNodesTest < Test::Unit::TestCase
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def test_should_raise_exception_without_event
|
110
|
-
|
110
|
+
assert_raises(IndexError) {
|
111
|
+
EnumStateMachine::Transition.new(@object, @machine, nil, :parked, :idling)
|
112
|
+
}
|
111
113
|
end
|
112
114
|
|
113
115
|
def test_should_raise_exception_with_invalid_event
|
114
|
-
|
116
|
+
assert_raises(IndexError) {
|
117
|
+
EnumStateMachine::Transition.new(@object, @machine, :invalid, :parked, :idling)
|
118
|
+
}
|
115
119
|
end
|
116
120
|
|
117
121
|
def test_should_raise_exception_with_invalid_from_state
|
118
|
-
|
122
|
+
assert_raises(IndexError) {
|
123
|
+
EnumStateMachine::Transition.new(@object, @machine, :ignite, :invalid, :idling)
|
124
|
+
}
|
119
125
|
end
|
120
126
|
|
121
127
|
def test_should_raise_exception_with_invalid_to_state
|
122
|
-
|
128
|
+
assert_raises(IndexError) {
|
129
|
+
EnumStateMachine::Transition.new(@object, @machine, :ignite, :parked, :invalid)
|
130
|
+
}
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|
126
|
-
class TransitionWithDynamicToValueTest < Test
|
134
|
+
class TransitionWithDynamicToValueTest < MiniTest::Test
|
127
135
|
def setup
|
128
136
|
@klass = Class.new
|
129
137
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -141,7 +149,7 @@ class TransitionWithDynamicToValueTest < Test::Unit::TestCase
|
|
141
149
|
end
|
142
150
|
end
|
143
151
|
|
144
|
-
class TransitionLoopbackTest < Test
|
152
|
+
class TransitionLoopbackTest < MiniTest::Test
|
145
153
|
def setup
|
146
154
|
@klass = Class.new
|
147
155
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -158,7 +166,7 @@ class TransitionLoopbackTest < Test::Unit::TestCase
|
|
158
166
|
end
|
159
167
|
end
|
160
168
|
|
161
|
-
class TransitionWithDifferentStatesTest < Test
|
169
|
+
class TransitionWithDifferentStatesTest < MiniTest::Test
|
162
170
|
def setup
|
163
171
|
@klass = Class.new
|
164
172
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -175,7 +183,7 @@ class TransitionWithDifferentStatesTest < Test::Unit::TestCase
|
|
175
183
|
end
|
176
184
|
end
|
177
185
|
|
178
|
-
class TransitionWithNamespaceTest < Test
|
186
|
+
class TransitionWithNamespaceTest < MiniTest::Test
|
179
187
|
def setup
|
180
188
|
@klass = Class.new
|
181
189
|
@machine = EnumStateMachine::Machine.new(@klass, :namespace => 'alarm')
|
@@ -221,7 +229,7 @@ class TransitionWithNamespaceTest < Test::Unit::TestCase
|
|
221
229
|
end
|
222
230
|
end
|
223
231
|
|
224
|
-
class TransitionWithCustomMachineAttributeTest < Test
|
232
|
+
class TransitionWithCustomMachineAttributeTest < MiniTest::Test
|
225
233
|
def setup
|
226
234
|
@klass = Class.new
|
227
235
|
@machine = EnumStateMachine::Machine.new(@klass, :state, :attribute => :state_id)
|
@@ -248,7 +256,7 @@ class TransitionWithCustomMachineAttributeTest < Test::Unit::TestCase
|
|
248
256
|
end
|
249
257
|
end
|
250
258
|
|
251
|
-
class TransitionWithoutReadingStateTest < Test
|
259
|
+
class TransitionWithoutReadingStateTest < MiniTest::Test
|
252
260
|
def setup
|
253
261
|
@klass = Class.new
|
254
262
|
@machine = EnumStateMachine::Machine.new(@klass)
|
@@ -269,7 +277,7 @@ class TransitionWithoutReadingStateTest < Test::Unit::TestCase
|
|
269
277
|
end
|
270
278
|
end
|
271
279
|
|
272
|
-
class TransitionWithActionTest < Test
|
280
|
+
class TransitionWithActionTest < MiniTest::Test
|
273
281
|
def setup
|
274
282
|
@klass = Class.new do
|
275
283
|
def save
|
@@ -295,7 +303,7 @@ class TransitionWithActionTest < Test::Unit::TestCase
|
|
295
303
|
end
|
296
304
|
end
|
297
305
|
|
298
|
-
class TransitionAfterBeingPersistedTest < Test
|
306
|
+
class TransitionAfterBeingPersistedTest < MiniTest::Test
|
299
307
|
def setup
|
300
308
|
@klass = Class.new
|
301
309
|
@machine = EnumStateMachine::Machine.new(@klass, :action => :save)
|
@@ -340,7 +348,7 @@ class TransitionAfterBeingPersistedTest < Test::Unit::TestCase
|
|
340
348
|
end
|
341
349
|
end
|
342
350
|
|
343
|
-
class TransitionAfterBeingRolledBackTest < Test
|
351
|
+
class TransitionAfterBeingRolledBackTest < MiniTest::Test
|
344
352
|
def setup
|
345
353
|
@klass = Class.new
|
346
354
|
@machine = EnumStateMachine::Machine.new(@klass, :action => :save)
|
@@ -374,7 +382,7 @@ class TransitionAfterBeingRolledBackTest < Test::Unit::TestCase
|
|
374
382
|
end
|
375
383
|
end
|
376
384
|
|
377
|
-
class TransitionWithoutCallbacksTest < Test
|
385
|
+
class TransitionWithoutCallbacksTest < MiniTest::Test
|
378
386
|
def setup
|
379
387
|
@klass = Class.new
|
380
388
|
|
@@ -406,7 +414,7 @@ class TransitionWithoutCallbacksTest < Test::Unit::TestCase
|
|
406
414
|
end
|
407
415
|
end
|
408
416
|
|
409
|
-
class TransitionWithBeforeCallbacksTest < Test
|
417
|
+
class TransitionWithBeforeCallbacksTest < MiniTest::Test
|
410
418
|
def setup
|
411
419
|
@klass = Class.new
|
412
420
|
|
@@ -457,7 +465,7 @@ class TransitionWithBeforeCallbacksTest < Test::Unit::TestCase
|
|
457
465
|
|
458
466
|
def test_should_not_catch_exceptions
|
459
467
|
@machine.before_transition {raise ArgumentError}
|
460
|
-
|
468
|
+
assert_raises(ArgumentError) { @transition.run_callbacks }
|
461
469
|
end
|
462
470
|
|
463
471
|
def test_should_not_be_able_to_run_twice
|
@@ -510,7 +518,7 @@ class TransitionWithBeforeCallbacksTest < Test::Unit::TestCase
|
|
510
518
|
end
|
511
519
|
end
|
512
520
|
|
513
|
-
class TransitionWithMultipleBeforeCallbacksTest < Test
|
521
|
+
class TransitionWithMultipleBeforeCallbacksTest < MiniTest::Test
|
514
522
|
def setup
|
515
523
|
@klass = Class.new
|
516
524
|
|
@@ -549,7 +557,7 @@ class TransitionWithMultipleBeforeCallbacksTest < Test::Unit::TestCase
|
|
549
557
|
end
|
550
558
|
end
|
551
559
|
|
552
|
-
class TransitionWithAfterCallbacksTest < Test
|
560
|
+
class TransitionWithAfterCallbacksTest < MiniTest::Test
|
553
561
|
def setup
|
554
562
|
@klass = Class.new
|
555
563
|
|
@@ -613,7 +621,7 @@ class TransitionWithAfterCallbacksTest < Test::Unit::TestCase
|
|
613
621
|
|
614
622
|
def test_should_not_catch_exceptions
|
615
623
|
@machine.after_transition {raise ArgumentError}
|
616
|
-
|
624
|
+
assert_raises(ArgumentError) { @transition.run_callbacks }
|
617
625
|
end
|
618
626
|
|
619
627
|
def test_should_not_be_able_to_run_twice
|
@@ -642,7 +650,7 @@ class TransitionWithAfterCallbacksTest < Test::Unit::TestCase
|
|
642
650
|
end
|
643
651
|
end
|
644
652
|
|
645
|
-
class TransitionWithMultipleAfterCallbacksTest < Test
|
653
|
+
class TransitionWithMultipleAfterCallbacksTest < MiniTest::Test
|
646
654
|
def setup
|
647
655
|
@klass = Class.new
|
648
656
|
|
@@ -681,7 +689,7 @@ class TransitionWithMultipleAfterCallbacksTest < Test::Unit::TestCase
|
|
681
689
|
end
|
682
690
|
end
|
683
691
|
|
684
|
-
class TransitionWithAroundCallbacksTest < Test
|
692
|
+
class TransitionWithAroundCallbacksTest < MiniTest::Test
|
685
693
|
def setup
|
686
694
|
@klass = Class.new
|
687
695
|
|
@@ -757,12 +765,12 @@ class TransitionWithAroundCallbacksTest < Test::Unit::TestCase
|
|
757
765
|
|
758
766
|
def test_should_not_catch_before_yield
|
759
767
|
@machine.around_transition {raise ArgumentError}
|
760
|
-
|
768
|
+
assert_raises(ArgumentError) { @transition.run_callbacks }
|
761
769
|
end
|
762
770
|
|
763
771
|
def test_should_not_catch_after_yield
|
764
772
|
@machine.around_transition {|block| block.call; raise ArgumentError}
|
765
|
-
|
773
|
+
assert_raises(ArgumentError) { @transition.run_callbacks }
|
766
774
|
end
|
767
775
|
|
768
776
|
def test_should_fail_if_not_yielded
|
@@ -824,7 +832,7 @@ class TransitionWithAroundCallbacksTest < Test::Unit::TestCase
|
|
824
832
|
end
|
825
833
|
end
|
826
834
|
|
827
|
-
class TransitionWithMultipleAroundCallbacksTest < Test
|
835
|
+
class TransitionWithMultipleAroundCallbacksTest < MiniTest::Test
|
828
836
|
def setup
|
829
837
|
@klass = Class.new
|
830
838
|
|
@@ -937,7 +945,7 @@ class TransitionWithMultipleAroundCallbacksTest < Test::Unit::TestCase
|
|
937
945
|
end
|
938
946
|
end
|
939
947
|
|
940
|
-
class TransitionWithFailureCallbacksTest < Test
|
948
|
+
class TransitionWithFailureCallbacksTest < MiniTest::Test
|
941
949
|
def setup
|
942
950
|
@klass = Class.new
|
943
951
|
|
@@ -992,7 +1000,7 @@ class TransitionWithFailureCallbacksTest < Test::Unit::TestCase
|
|
992
1000
|
|
993
1001
|
def test_should_not_catch_exceptions
|
994
1002
|
@machine.after_failure {raise ArgumentError}
|
995
|
-
|
1003
|
+
assert_raises(ArgumentError) { @transition.run_callbacks {{:success => false}} }
|
996
1004
|
end
|
997
1005
|
|
998
1006
|
def test_should_not_be_able_to_run_twice
|
@@ -1021,7 +1029,7 @@ class TransitionWithFailureCallbacksTest < Test::Unit::TestCase
|
|
1021
1029
|
end
|
1022
1030
|
end
|
1023
1031
|
|
1024
|
-
class TransitionWithMultipleFailureCallbacksTest < Test
|
1032
|
+
class TransitionWithMultipleFailureCallbacksTest < MiniTest::Test
|
1025
1033
|
def setup
|
1026
1034
|
@klass = Class.new
|
1027
1035
|
|
@@ -1060,7 +1068,7 @@ class TransitionWithMultipleFailureCallbacksTest < Test::Unit::TestCase
|
|
1060
1068
|
end
|
1061
1069
|
end
|
1062
1070
|
|
1063
|
-
class TransitionWithMixedCallbacksTest < Test
|
1071
|
+
class TransitionWithMixedCallbacksTest < MiniTest::Test
|
1064
1072
|
def setup
|
1065
1073
|
@klass = Class.new
|
1066
1074
|
|
@@ -1164,7 +1172,7 @@ class TransitionWithMixedCallbacksTest < Test::Unit::TestCase
|
|
1164
1172
|
end
|
1165
1173
|
end
|
1166
1174
|
|
1167
|
-
class TransitionWithBeforeCallbacksSkippedTest < Test
|
1175
|
+
class TransitionWithBeforeCallbacksSkippedTest < MiniTest::Test
|
1168
1176
|
def setup
|
1169
1177
|
@klass = Class.new
|
1170
1178
|
|
@@ -1193,7 +1201,7 @@ class TransitionWithBeforeCallbacksSkippedTest < Test::Unit::TestCase
|
|
1193
1201
|
end
|
1194
1202
|
end
|
1195
1203
|
|
1196
|
-
class TransitionWithAfterCallbacksSkippedTest < Test
|
1204
|
+
class TransitionWithAfterCallbacksSkippedTest < MiniTest::Test
|
1197
1205
|
def setup
|
1198
1206
|
@klass = Class.new
|
1199
1207
|
|
@@ -1305,7 +1313,7 @@ class TransitionWithAfterCallbacksSkippedTest < Test::Unit::TestCase
|
|
1305
1313
|
@machine.around_transition {|block| block.call; raise ArgumentError}
|
1306
1314
|
|
1307
1315
|
assert_nothing_raised { @transition.run_callbacks(:after => false) }
|
1308
|
-
|
1316
|
+
assert_raises(ArgumentError) { @transition.run_callbacks }
|
1309
1317
|
end
|
1310
1318
|
else
|
1311
1319
|
def test_should_raise_exception_on_second_call
|
@@ -1314,12 +1322,12 @@ class TransitionWithAfterCallbacksSkippedTest < Test::Unit::TestCase
|
|
1314
1322
|
@machine.around_transition {|block| @callbacks << :before_around_2; block.call; @callbacks << :after_around_2}
|
1315
1323
|
@machine.after_transition {@callbacks << :after}
|
1316
1324
|
|
1317
|
-
|
1325
|
+
assert_raises(ArgumentError) { @transition.run_callbacks(:after => false) }
|
1318
1326
|
end
|
1319
1327
|
end
|
1320
1328
|
end
|
1321
1329
|
|
1322
|
-
class TransitionAfterBeingPerformedTest < Test
|
1330
|
+
class TransitionAfterBeingPerformedTest < MiniTest::Test
|
1323
1331
|
def setup
|
1324
1332
|
@klass = Class.new do
|
1325
1333
|
attr_reader :saved, :save_state
|
@@ -1366,7 +1374,7 @@ class TransitionAfterBeingPerformedTest < Test::Unit::TestCase
|
|
1366
1374
|
end
|
1367
1375
|
end
|
1368
1376
|
|
1369
|
-
class TransitionWithPerformArgumentsTest < Test
|
1377
|
+
class TransitionWithPerformArgumentsTest < MiniTest::Test
|
1370
1378
|
def setup
|
1371
1379
|
@klass = Class.new do
|
1372
1380
|
attr_reader :saved
|
@@ -1400,7 +1408,7 @@ class TransitionWithPerformArgumentsTest < Test::Unit::TestCase
|
|
1400
1408
|
end
|
1401
1409
|
end
|
1402
1410
|
|
1403
|
-
class TransitionWithoutRunningActionTest < Test
|
1411
|
+
class TransitionWithoutRunningActionTest < MiniTest::Test
|
1404
1412
|
def setup
|
1405
1413
|
@klass = Class.new do
|
1406
1414
|
attr_reader :saved
|
@@ -1446,7 +1454,7 @@ class TransitionWithoutRunningActionTest < Test::Unit::TestCase
|
|
1446
1454
|
end
|
1447
1455
|
end
|
1448
1456
|
|
1449
|
-
class TransitionWithTransactionsTest < Test
|
1457
|
+
class TransitionWithTransactionsTest < MiniTest::Test
|
1450
1458
|
def setup
|
1451
1459
|
@klass = Class.new do
|
1452
1460
|
class << self
|
@@ -1487,7 +1495,7 @@ class TransitionWithTransactionsTest < Test::Unit::TestCase
|
|
1487
1495
|
end
|
1488
1496
|
end
|
1489
1497
|
|
1490
|
-
class TransitionTransientTest < Test
|
1498
|
+
class TransitionTransientTest < MiniTest::Test
|
1491
1499
|
def setup
|
1492
1500
|
@klass = Class.new
|
1493
1501
|
|
@@ -1506,7 +1514,7 @@ class TransitionTransientTest < Test::Unit::TestCase
|
|
1506
1514
|
end
|
1507
1515
|
end
|
1508
1516
|
|
1509
|
-
class TransitionEqualityTest < Test
|
1517
|
+
class TransitionEqualityTest < MiniTest::Test
|
1510
1518
|
def setup
|
1511
1519
|
@klass = Class.new
|
1512
1520
|
|
@@ -1530,29 +1538,29 @@ class TransitionEqualityTest < Test::Unit::TestCase
|
|
1530
1538
|
machine.event :ignite
|
1531
1539
|
transition = EnumStateMachine::Transition.new(@object, machine, :ignite, :parked, :idling)
|
1532
1540
|
|
1533
|
-
|
1541
|
+
refute_equal transition, @transition
|
1534
1542
|
end
|
1535
1543
|
|
1536
1544
|
def test_should_not_be_equal_with_different_objects
|
1537
1545
|
transition = EnumStateMachine::Transition.new(@klass.new, @machine, :ignite, :parked, :idling)
|
1538
|
-
|
1546
|
+
refute_equal transition, @transition
|
1539
1547
|
end
|
1540
1548
|
|
1541
1549
|
def test_should_not_be_equal_with_different_event_names
|
1542
1550
|
@machine.event :park
|
1543
1551
|
transition = EnumStateMachine::Transition.new(@object, @machine, :park, :parked, :idling)
|
1544
|
-
|
1552
|
+
refute_equal transition, @transition
|
1545
1553
|
end
|
1546
1554
|
|
1547
1555
|
def test_should_not_be_equal_with_different_from_state_names
|
1548
1556
|
@machine.state :first_gear
|
1549
1557
|
transition = EnumStateMachine::Transition.new(@object, @machine, :ignite, :first_gear, :idling)
|
1550
|
-
|
1558
|
+
refute_equal transition, @transition
|
1551
1559
|
end
|
1552
1560
|
|
1553
1561
|
def test_should_not_be_equal_with_different_to_state_names
|
1554
1562
|
@machine.state :first_gear
|
1555
1563
|
transition = EnumStateMachine::Transition.new(@object, @machine, :ignite, :idling, :first_gear)
|
1556
|
-
|
1564
|
+
refute_equal transition, @transition
|
1557
1565
|
end
|
1558
1566
|
end
|