enum_state_machine 0.9.0 → 0.10.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/.ruby-version +1 -1
- data/enum_state_machine.gemspec +2 -2
- data/lib/enum_state_machine/event.rb +1 -1
- data/lib/enum_state_machine/machine.rb +2 -2
- data/lib/enum_state_machine/state.rb +1 -1
- data/lib/enum_state_machine/version.rb +1 -1
- data/test/functional/state_machine_test.rb +20 -20
- data/test/test_helper.rb +15 -1
- data/test/unit/assertions_test.rb +1 -1
- data/test/unit/branch_test.rb +42 -42
- data/test/unit/callback_test.rb +27 -27
- data/test/unit/error_test.rb +2 -2
- data/test/unit/eval_helpers_test.rb +1 -1
- data/test/unit/event_collection_test.rb +10 -10
- data/test/unit/event_test.rb +38 -38
- data/test/unit/graph_test.rb +4 -4
- data/test/unit/helper_module_test.rb +1 -1
- data/test/unit/integrations/active_model_test.rb +1 -1
- data/test/unit/integrations/active_record_test.rb +15 -15
- data/test/unit/integrations/base_test.rb +2 -2
- data/test/unit/integrations_test.rb +2 -2
- 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 +15 -15
- data/test/unit/machine_test.rb +114 -114
- data/test/unit/matcher_helpers_test.rb +3 -3
- data/test/unit/matcher_test.rb +7 -7
- data/test/unit/node_collection_test.rb +13 -13
- data/test/unit/path_collection_test.rb +8 -8
- data/test/unit/path_test.rb +13 -13
- data/test/unit/state_collection_test.rb +10 -10
- data/test/unit/state_context_test.rb +10 -10
- data/test/unit/state_enum_test.rb +1 -1
- data/test/unit/state_machine_test.rb +2 -2
- data/test/unit/state_test.rb +52 -52
- data/test/unit/transition_collection_test.rb +41 -41
- data/test/unit/transition_test.rb +29 -29
- metadata +10 -10
data/test/unit/callback_test.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
2
2
|
|
|
3
|
-
class CallbackTest <
|
|
3
|
+
class CallbackTest < Minitest::Test
|
|
4
4
|
def test_should_raise_exception_if_invalid_type_specified
|
|
5
5
|
exception = assert_raises(ArgumentError) { EnumStateMachine::Callback.new(:invalid) {} }
|
|
6
6
|
assert_equal 'Type must be :before, :after, :around, or :failure', exception.message
|
|
@@ -52,7 +52,7 @@ class CallbackTest < MiniTest::Test
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
class CallbackByDefaultTest <
|
|
55
|
+
class CallbackByDefaultTest < Minitest::Test
|
|
56
56
|
def setup
|
|
57
57
|
@callback = EnumStateMachine::Callback.new(:before) {}
|
|
58
58
|
end
|
|
@@ -76,7 +76,7 @@ class CallbackByDefaultTest < MiniTest::Test
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
class CallbackWithMethodArgumentTest <
|
|
79
|
+
class CallbackWithMethodArgumentTest < Minitest::Test
|
|
80
80
|
def setup
|
|
81
81
|
@callback = EnumStateMachine::Callback.new(:before, lambda {|*args| @args = args})
|
|
82
82
|
|
|
@@ -93,7 +93,7 @@ class CallbackWithMethodArgumentTest < MiniTest::Test
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
class CallbackWithMultipleMethodArgumentsTest <
|
|
96
|
+
class CallbackWithMultipleMethodArgumentsTest < Minitest::Test
|
|
97
97
|
def setup
|
|
98
98
|
@callback = EnumStateMachine::Callback.new(:before, :run_1, :run_2)
|
|
99
99
|
|
|
@@ -121,7 +121,7 @@ class CallbackWithMultipleMethodArgumentsTest < MiniTest::Test
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
class CallbackWithDoMethodTest <
|
|
124
|
+
class CallbackWithDoMethodTest < Minitest::Test
|
|
125
125
|
def setup
|
|
126
126
|
@callback = EnumStateMachine::Callback.new(:before, :do => lambda {|*args| @args = args})
|
|
127
127
|
|
|
@@ -138,7 +138,7 @@ class CallbackWithDoMethodTest < MiniTest::Test
|
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
class CallbackWithMultipleDoMethodsTest <
|
|
141
|
+
class CallbackWithMultipleDoMethodsTest < Minitest::Test
|
|
142
142
|
def setup
|
|
143
143
|
@callback = EnumStateMachine::Callback.new(:before, :do => [:run_1, :run_2])
|
|
144
144
|
|
|
@@ -166,7 +166,7 @@ class CallbackWithMultipleDoMethodsTest < MiniTest::Test
|
|
|
166
166
|
end
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
class CallbackWithBlockTest <
|
|
169
|
+
class CallbackWithBlockTest < Minitest::Test
|
|
170
170
|
def setup
|
|
171
171
|
@callback = EnumStateMachine::Callback.new(:before) do |*args|
|
|
172
172
|
@args = args
|
|
@@ -185,7 +185,7 @@ class CallbackWithBlockTest < MiniTest::Test
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
class CallbackWithMixedMethodsTest <
|
|
188
|
+
class CallbackWithMixedMethodsTest < Minitest::Test
|
|
189
189
|
def setup
|
|
190
190
|
@callback = EnumStateMachine::Callback.new(:before, :run_argument, :do => :run_do) do |object|
|
|
191
191
|
object.callbacks << :block
|
|
@@ -215,7 +215,7 @@ class CallbackWithMixedMethodsTest < MiniTest::Test
|
|
|
215
215
|
end
|
|
216
216
|
end
|
|
217
217
|
|
|
218
|
-
class CallbackWithExplicitRequirementsTest <
|
|
218
|
+
class CallbackWithExplicitRequirementsTest < Minitest::Test
|
|
219
219
|
def setup
|
|
220
220
|
@object = Object.new
|
|
221
221
|
@callback = EnumStateMachine::Callback.new(:before, :from => :parked, :to => :idling, :on => :ignite, :do => lambda {})
|
|
@@ -246,7 +246,7 @@ class CallbackWithExplicitRequirementsTest < MiniTest::Test
|
|
|
246
246
|
end
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
-
class CallbackWithImplicitRequirementsTest <
|
|
249
|
+
class CallbackWithImplicitRequirementsTest < Minitest::Test
|
|
250
250
|
def setup
|
|
251
251
|
@object = Object.new
|
|
252
252
|
@callback = EnumStateMachine::Callback.new(:before, :parked => :idling, :on => :ignite, :do => lambda {})
|
|
@@ -277,7 +277,7 @@ class CallbackWithImplicitRequirementsTest < MiniTest::Test
|
|
|
277
277
|
end
|
|
278
278
|
end
|
|
279
279
|
|
|
280
|
-
class CallbackWithIfConditionTest <
|
|
280
|
+
class CallbackWithIfConditionTest < Minitest::Test
|
|
281
281
|
def setup
|
|
282
282
|
@object = Object.new
|
|
283
283
|
end
|
|
@@ -293,7 +293,7 @@ class CallbackWithIfConditionTest < MiniTest::Test
|
|
|
293
293
|
end
|
|
294
294
|
end
|
|
295
295
|
|
|
296
|
-
class CallbackWithUnlessConditionTest <
|
|
296
|
+
class CallbackWithUnlessConditionTest < Minitest::Test
|
|
297
297
|
def setup
|
|
298
298
|
@object = Object.new
|
|
299
299
|
end
|
|
@@ -309,7 +309,7 @@ class CallbackWithUnlessConditionTest < MiniTest::Test
|
|
|
309
309
|
end
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
-
class CallbackWithoutTerminatorTest <
|
|
312
|
+
class CallbackWithoutTerminatorTest < Minitest::Test
|
|
313
313
|
def setup
|
|
314
314
|
@object = Object.new
|
|
315
315
|
end
|
|
@@ -320,7 +320,7 @@ class CallbackWithoutTerminatorTest < MiniTest::Test
|
|
|
320
320
|
end
|
|
321
321
|
end
|
|
322
322
|
|
|
323
|
-
class CallbackWithTerminatorTest <
|
|
323
|
+
class CallbackWithTerminatorTest < Minitest::Test
|
|
324
324
|
def setup
|
|
325
325
|
@object = Object.new
|
|
326
326
|
end
|
|
@@ -341,7 +341,7 @@ class CallbackWithTerminatorTest < MiniTest::Test
|
|
|
341
341
|
end
|
|
342
342
|
end
|
|
343
343
|
|
|
344
|
-
class CallbackWithoutArgumentsTest <
|
|
344
|
+
class CallbackWithoutArgumentsTest < Minitest::Test
|
|
345
345
|
def setup
|
|
346
346
|
@callback = EnumStateMachine::Callback.new(:before, :do => lambda {|object| @arg = object})
|
|
347
347
|
|
|
@@ -354,7 +354,7 @@ class CallbackWithoutArgumentsTest < MiniTest::Test
|
|
|
354
354
|
end
|
|
355
355
|
end
|
|
356
356
|
|
|
357
|
-
class CallbackWithArgumentsTest <
|
|
357
|
+
class CallbackWithArgumentsTest < Minitest::Test
|
|
358
358
|
def setup
|
|
359
359
|
@callback = EnumStateMachine::Callback.new(:before, :do => lambda {|*args| @args = args})
|
|
360
360
|
|
|
@@ -367,7 +367,7 @@ class CallbackWithArgumentsTest < MiniTest::Test
|
|
|
367
367
|
end
|
|
368
368
|
end
|
|
369
369
|
|
|
370
|
-
class CallbackWithUnboundMethodTest <
|
|
370
|
+
class CallbackWithUnboundMethodTest < Minitest::Test
|
|
371
371
|
def setup
|
|
372
372
|
@callback = EnumStateMachine::Callback.new(:before, :do => lambda {|*args| @context = args.unshift(self)})
|
|
373
373
|
|
|
@@ -380,7 +380,7 @@ class CallbackWithUnboundMethodTest < MiniTest::Test
|
|
|
380
380
|
end
|
|
381
381
|
end
|
|
382
382
|
|
|
383
|
-
class CallbackWithBoundMethodTest <
|
|
383
|
+
class CallbackWithBoundMethodTest < Minitest::Test
|
|
384
384
|
def setup
|
|
385
385
|
@object = Object.new
|
|
386
386
|
end
|
|
@@ -414,7 +414,7 @@ class CallbackWithBoundMethodTest < MiniTest::Test
|
|
|
414
414
|
end
|
|
415
415
|
end
|
|
416
416
|
|
|
417
|
-
class CallbackWithMultipleBoundMethodsTest <
|
|
417
|
+
class CallbackWithMultipleBoundMethodsTest < Minitest::Test
|
|
418
418
|
def setup
|
|
419
419
|
@object = Object.new
|
|
420
420
|
|
|
@@ -434,7 +434,7 @@ class CallbackWithMultipleBoundMethodsTest < MiniTest::Test
|
|
|
434
434
|
end
|
|
435
435
|
end
|
|
436
436
|
|
|
437
|
-
class CallbackWithApplicationBoundObjectTest <
|
|
437
|
+
class CallbackWithApplicationBoundObjectTest < Minitest::Test
|
|
438
438
|
def setup
|
|
439
439
|
@original_bind_to_object = EnumStateMachine::Callback.bind_to_object
|
|
440
440
|
EnumStateMachine::Callback.bind_to_object = true
|
|
@@ -456,7 +456,7 @@ class CallbackWithApplicationBoundObjectTest < MiniTest::Test
|
|
|
456
456
|
end
|
|
457
457
|
end
|
|
458
458
|
|
|
459
|
-
class CallbackWithBoundMethodAndArgumentsTest <
|
|
459
|
+
class CallbackWithBoundMethodAndArgumentsTest < Minitest::Test
|
|
460
460
|
def setup
|
|
461
461
|
@object = Object.new
|
|
462
462
|
end
|
|
@@ -483,7 +483,7 @@ class CallbackWithBoundMethodAndArgumentsTest < MiniTest::Test
|
|
|
483
483
|
end
|
|
484
484
|
end
|
|
485
485
|
|
|
486
|
-
class CallbackWithApplicationTerminatorTest <
|
|
486
|
+
class CallbackWithApplicationTerminatorTest < Minitest::Test
|
|
487
487
|
def setup
|
|
488
488
|
@original_terminator = EnumStateMachine::Callback.terminator
|
|
489
489
|
EnumStateMachine::Callback.terminator = lambda {|result| result == false}
|
|
@@ -506,7 +506,7 @@ class CallbackWithApplicationTerminatorTest < MiniTest::Test
|
|
|
506
506
|
end
|
|
507
507
|
end
|
|
508
508
|
|
|
509
|
-
class CallbackWithAroundTypeAndBlockTest <
|
|
509
|
+
class CallbackWithAroundTypeAndBlockTest < Minitest::Test
|
|
510
510
|
def setup
|
|
511
511
|
@object = Object.new
|
|
512
512
|
@callbacks = []
|
|
@@ -549,7 +549,7 @@ class CallbackWithAroundTypeAndBlockTest < MiniTest::Test
|
|
|
549
549
|
end
|
|
550
550
|
end
|
|
551
551
|
|
|
552
|
-
class CallbackWithAroundTypeAndMultipleMethodsTest <
|
|
552
|
+
class CallbackWithAroundTypeAndMultipleMethodsTest < Minitest::Test
|
|
553
553
|
def setup
|
|
554
554
|
@callback = EnumStateMachine::Callback.new(:around, :run_1, :run_2)
|
|
555
555
|
|
|
@@ -641,7 +641,7 @@ class CallbackWithAroundTypeAndMultipleMethodsTest < MiniTest::Test
|
|
|
641
641
|
end
|
|
642
642
|
end
|
|
643
643
|
|
|
644
|
-
class CallbackWithAroundTypeAndArgumentsTest <
|
|
644
|
+
class CallbackWithAroundTypeAndArgumentsTest < Minitest::Test
|
|
645
645
|
def setup
|
|
646
646
|
@object = Object.new
|
|
647
647
|
end
|
|
@@ -665,7 +665,7 @@ class CallbackWithAroundTypeAndArgumentsTest < MiniTest::Test
|
|
|
665
665
|
end
|
|
666
666
|
end
|
|
667
667
|
|
|
668
|
-
class CallbackWithAroundTypeAndTerminatorTest <
|
|
668
|
+
class CallbackWithAroundTypeAndTerminatorTest < Minitest::Test
|
|
669
669
|
def setup
|
|
670
670
|
@object = Object.new
|
|
671
671
|
end
|
|
@@ -681,7 +681,7 @@ class CallbackWithAroundTypeAndTerminatorTest < MiniTest::Test
|
|
|
681
681
|
end
|
|
682
682
|
end
|
|
683
683
|
|
|
684
|
-
class CallbackWithAroundTypeAndBoundMethodTest <
|
|
684
|
+
class CallbackWithAroundTypeAndBoundMethodTest < Minitest::Test
|
|
685
685
|
def setup
|
|
686
686
|
@object = Object.new
|
|
687
687
|
end
|
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 <
|
|
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,7 +20,7 @@ class ErrorByDefaultTest < MiniTest::Test
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
class ErrorWithMessageTest <
|
|
23
|
+
class ErrorWithMessageTest < Minitest::Test
|
|
24
24
|
def setup
|
|
25
25
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
|
26
26
|
@collection = EnumStateMachine::NodeCollection.new(@machine)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
2
2
|
|
|
3
|
-
class EventCollectionByDefaultTest <
|
|
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 < MiniTest::Test
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
class EventCollectionTest <
|
|
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 < MiniTest::Test
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
class EventStringCollectionTest <
|
|
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 < MiniTest::Test
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
class EventCollectionWithEventsWithTransitionsTest <
|
|
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 < MiniTest::Test
|
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
class EventCollectionWithMultipleEventsTest <
|
|
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 < MiniTest::Test
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
class EventCollectionWithoutMachineActionTest <
|
|
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 < MiniTest::Test
|
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
class EventCollectionAttributeWithMachineActionTest <
|
|
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 < MiniTest::Test
|
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
-
class EventCollectionAttributeWithNamespacedMachineTest <
|
|
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 < MiniTest::Test
|
|
|
297
297
|
end
|
|
298
298
|
end
|
|
299
299
|
|
|
300
|
-
class EventCollectionWithValidationsTest <
|
|
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 < MiniTest::Test
|
|
|
367
367
|
end
|
|
368
368
|
end
|
|
369
369
|
|
|
370
|
-
class EventCollectionWithCustomMachineAttributeTest <
|
|
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 <
|
|
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 < MiniTest::Test
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
class EventTest <
|
|
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 < MiniTest::Test
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
class EventWithHumanNameTest <
|
|
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 < MiniTest::Test
|
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
class EventWithDynamicHumanNameTest <
|
|
106
|
+
class EventWithDynamicHumanNameTest < Minitest::Test
|
|
107
107
|
def setup
|
|
108
108
|
@klass = Class.new
|
|
109
109
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -127,10 +127,10 @@ class EventWithDynamicHumanNameTest < MiniTest::Test
|
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
class EventWithConflictingHelpersBeforeDefinitionTest <
|
|
130
|
+
class EventWithConflictingHelpersBeforeDefinitionTest < Minitest::Test
|
|
131
131
|
def setup
|
|
132
132
|
require 'stringio'
|
|
133
|
-
@
|
|
133
|
+
set_rails_logger(@io = StringIO.new)
|
|
134
134
|
|
|
135
135
|
@superclass = Class.new do
|
|
136
136
|
def can_ignite?
|
|
@@ -176,18 +176,18 @@ class EventWithConflictingHelpersBeforeDefinitionTest < MiniTest::Test
|
|
|
176
176
|
"Instance method \"#{method}\" is already defined in #{@superclass.to_s}, use generic helper instead or set EnumStateMachine::Machine.ignore_method_conflicts = true.\n"
|
|
177
177
|
end.join
|
|
178
178
|
|
|
179
|
-
assert_equal expected,
|
|
179
|
+
assert_equal expected, @io.string
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
def teardown
|
|
183
|
-
|
|
183
|
+
reset_rails_logger
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
|
|
187
|
-
class EventWithConflictingHelpersAfterDefinitionTest <
|
|
187
|
+
class EventWithConflictingHelpersAfterDefinitionTest < Minitest::Test
|
|
188
188
|
def setup
|
|
189
189
|
require 'stringio'
|
|
190
|
-
@
|
|
190
|
+
set_rails_logger(@io = StringIO.new)
|
|
191
191
|
|
|
192
192
|
@klass = Class.new do
|
|
193
193
|
def can_ignite?
|
|
@@ -253,18 +253,18 @@ class EventWithConflictingHelpersAfterDefinitionTest < MiniTest::Test
|
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
def test_should_not_output_warning
|
|
256
|
-
assert_equal '',
|
|
256
|
+
assert_equal '', @io.string
|
|
257
257
|
end
|
|
258
258
|
|
|
259
259
|
def teardown
|
|
260
|
-
|
|
260
|
+
reset_rails_logger
|
|
261
261
|
end
|
|
262
262
|
end
|
|
263
263
|
|
|
264
|
-
class EventWithConflictingMachineTest <
|
|
264
|
+
class EventWithConflictingMachineTest < Minitest::Test
|
|
265
265
|
def setup
|
|
266
266
|
require 'stringio'
|
|
267
|
-
@
|
|
267
|
+
set_rails_logger(@io = StringIO.new)
|
|
268
268
|
|
|
269
269
|
@klass = Class.new
|
|
270
270
|
@state_machine = EnumStateMachine::Machine.new(@klass, :state)
|
|
@@ -293,22 +293,22 @@ class EventWithConflictingMachineTest < MiniTest::Test
|
|
|
293
293
|
@status_machine = EnumStateMachine::Machine.new(@klass, :status)
|
|
294
294
|
@status_machine.events << @status_event = EnumStateMachine::Event.new(@status_machine, :ignite)
|
|
295
295
|
|
|
296
|
-
assert_equal "Event :ignite for :status is already defined in :state\n",
|
|
296
|
+
assert_equal "Event :ignite for :status is already defined in :state\n", @io.string
|
|
297
297
|
end
|
|
298
298
|
|
|
299
299
|
def test_should_not_output_warning_if_using_different_namespace
|
|
300
300
|
@status_machine = EnumStateMachine::Machine.new(@klass, :status, :namespace => 'alarm')
|
|
301
301
|
@status_machine.events << @status_event = EnumStateMachine::Event.new(@status_machine, :ignite)
|
|
302
302
|
|
|
303
|
-
assert_equal '',
|
|
303
|
+
assert_equal '', @io.string
|
|
304
304
|
end
|
|
305
305
|
|
|
306
306
|
def teardown
|
|
307
|
-
|
|
307
|
+
reset_rails_logger
|
|
308
308
|
end
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
class EventWithNamespaceTest <
|
|
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 < MiniTest::Test
|
|
|
341
341
|
end
|
|
342
342
|
end
|
|
343
343
|
|
|
344
|
-
class EventContextTest <
|
|
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 < MiniTest::Test
|
|
|
355
355
|
end
|
|
356
356
|
end
|
|
357
357
|
|
|
358
|
-
class EventTransitionsTest <
|
|
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)
|
|
@@ -415,7 +415,7 @@ class EventTransitionsTest < MiniTest::Test
|
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
418
|
-
class EventAfterBeingCopiedTest <
|
|
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)
|
|
@@ -431,7 +431,7 @@ class EventAfterBeingCopiedTest < MiniTest::Test
|
|
|
431
431
|
end
|
|
432
432
|
end
|
|
433
433
|
|
|
434
|
-
class EventWithoutTransitionsTest <
|
|
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 < MiniTest::Test
|
|
|
457
457
|
end
|
|
458
458
|
end
|
|
459
459
|
|
|
460
|
-
class EventWithTransitionsTest <
|
|
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 < MiniTest::Test
|
|
|
487
487
|
end
|
|
488
488
|
end
|
|
489
489
|
|
|
490
|
-
class EventWithoutMatchingTransitionsTest <
|
|
490
|
+
class EventWithoutMatchingTransitionsTest < Minitest::Test
|
|
491
491
|
def setup
|
|
492
492
|
@klass = Class.new
|
|
493
493
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -526,7 +526,7 @@ class EventWithoutMatchingTransitionsTest < MiniTest::Test
|
|
|
526
526
|
end
|
|
527
527
|
end
|
|
528
528
|
|
|
529
|
-
class EventWithMatchingDisabledTransitionsTest <
|
|
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
|
|
@@ -637,7 +637,7 @@ class EventWithMatchingDisabledTransitionsTest < MiniTest::Test
|
|
|
637
637
|
end
|
|
638
638
|
end
|
|
639
639
|
|
|
640
|
-
class EventWithMatchingEnabledTransitionsTest <
|
|
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
|
|
@@ -708,7 +708,7 @@ class EventWithMatchingEnabledTransitionsTest < MiniTest::Test
|
|
|
708
708
|
end
|
|
709
709
|
end
|
|
710
710
|
|
|
711
|
-
class EventWithTransitionWithoutToStateTest <
|
|
711
|
+
class EventWithTransitionWithoutToStateTest < Minitest::Test
|
|
712
712
|
def setup
|
|
713
713
|
@klass = Class.new
|
|
714
714
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -743,7 +743,7 @@ class EventWithTransitionWithoutToStateTest < MiniTest::Test
|
|
|
743
743
|
end
|
|
744
744
|
end
|
|
745
745
|
|
|
746
|
-
class EventWithTransitionWithNilToStateTest <
|
|
746
|
+
class EventWithTransitionWithNilToStateTest < Minitest::Test
|
|
747
747
|
def setup
|
|
748
748
|
@klass = Class.new
|
|
749
749
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -778,7 +778,7 @@ class EventWithTransitionWithNilToStateTest < MiniTest::Test
|
|
|
778
778
|
end
|
|
779
779
|
end
|
|
780
780
|
|
|
781
|
-
class EventWithTransitionWithLoopbackStateTest <
|
|
781
|
+
class EventWithTransitionWithLoopbackStateTest < Minitest::Test
|
|
782
782
|
def setup
|
|
783
783
|
@klass = Class.new
|
|
784
784
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -813,7 +813,7 @@ class EventWithTransitionWithLoopbackStateTest < MiniTest::Test
|
|
|
813
813
|
end
|
|
814
814
|
end
|
|
815
815
|
|
|
816
|
-
class EventWithTransitionWithBlacklistedToStateTest <
|
|
816
|
+
class EventWithTransitionWithBlacklistedToStateTest < Minitest::Test
|
|
817
817
|
def setup
|
|
818
818
|
@klass = Class.new
|
|
819
819
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
|
@@ -873,7 +873,7 @@ class EventWithTransitionWithBlacklistedToStateTest < MiniTest::Test
|
|
|
873
873
|
end
|
|
874
874
|
end
|
|
875
875
|
|
|
876
|
-
class EventWithTransitionWithWhitelistedToStateTest <
|
|
876
|
+
class EventWithTransitionWithWhitelistedToStateTest < Minitest::Test
|
|
877
877
|
def setup
|
|
878
878
|
@klass = Class.new
|
|
879
879
|
@machine = EnumStateMachine::Machine.new(@klass, :initial => :parked)
|
|
@@ -922,7 +922,7 @@ class EventWithTransitionWithWhitelistedToStateTest < MiniTest::Test
|
|
|
922
922
|
end
|
|
923
923
|
end
|
|
924
924
|
|
|
925
|
-
class EventWithMultipleTransitionsTest <
|
|
925
|
+
class EventWithMultipleTransitionsTest < Minitest::Test
|
|
926
926
|
def setup
|
|
927
927
|
@klass = Class.new
|
|
928
928
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -982,7 +982,7 @@ class EventWithMultipleTransitionsTest < MiniTest::Test
|
|
|
982
982
|
end
|
|
983
983
|
end
|
|
984
984
|
|
|
985
|
-
class EventWithMachineActionTest <
|
|
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 < MiniTest::Test
|
|
|
1013
1013
|
end
|
|
1014
1014
|
end
|
|
1015
1015
|
|
|
1016
|
-
class EventWithInvalidCurrentStateTest <
|
|
1016
|
+
class EventWithInvalidCurrentStateTest < Minitest::Test
|
|
1017
1017
|
def setup
|
|
1018
1018
|
@klass = Class.new
|
|
1019
1019
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -1042,7 +1042,7 @@ class EventWithInvalidCurrentStateTest < MiniTest::Test
|
|
|
1042
1042
|
end
|
|
1043
1043
|
end
|
|
1044
1044
|
|
|
1045
|
-
class EventOnFailureTest <
|
|
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
|
|
@@ -1094,7 +1094,7 @@ class EventOnFailureTest < MiniTest::Test
|
|
|
1094
1094
|
end
|
|
1095
1095
|
end
|
|
1096
1096
|
|
|
1097
|
-
class EventWithMarshallingTest <
|
|
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 <
|
|
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 <
|
|
1173
|
+
class EventDrawingWithHumanNameTest < Minitest::Test
|
|
1174
1174
|
def setup
|
|
1175
1175
|
states = [:parked, :idling]
|
|
1176
1176
|
|
data/test/unit/graph_test.rb
CHANGED
|
@@ -8,7 +8,7 @@ begin
|
|
|
8
8
|
(RUBY_PLATFORM =~ /darwin/) ? 'ArialMT' : 'Arial'
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
class GraphDefaultTest <
|
|
11
|
+
class GraphDefaultTest < Minitest::Test
|
|
12
12
|
def setup
|
|
13
13
|
@graph = EnumStateMachine::Graph.new('test')
|
|
14
14
|
end
|
|
@@ -30,7 +30,7 @@ begin
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
class GraphNodesTest <
|
|
33
|
+
class GraphNodesTest < Minitest::Test
|
|
34
34
|
def setup
|
|
35
35
|
@graph = EnumStateMachine::Graph.new('test')
|
|
36
36
|
@node = @graph.add_nodes('parked', :shape => 'ellipse')
|
|
@@ -53,7 +53,7 @@ begin
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
class GraphEdgesTest <
|
|
56
|
+
class GraphEdgesTest < Minitest::Test
|
|
57
57
|
def setup
|
|
58
58
|
@graph = EnumStateMachine::Graph.new('test')
|
|
59
59
|
@graph.add_nodes('parked', :shape => 'ellipse')
|
|
@@ -79,7 +79,7 @@ begin
|
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
class GraphOutputTest <
|
|
82
|
+
class GraphOutputTest < Minitest::Test
|
|
83
83
|
def setup
|
|
84
84
|
@graph_name = "test_#{rand(1000000)}"
|
|
85
85
|
@graph = EnumStateMachine::Graph.new(@graph_name)
|