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/branch_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class BranchTest < Test
|
3
|
+
class BranchTest < MiniTest::Test
|
4
4
|
def setup
|
5
5
|
@branch = EnumStateMachine::Branch.new(:from => :parked, :to => :idling)
|
6
6
|
end
|
@@ -22,12 +22,12 @@ class BranchTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_should_raise_an_exception_if_invalid_match_option_specified
|
25
|
-
exception =
|
25
|
+
exception = assert_raises(ArgumentError) { @branch.match(Object.new, :invalid => true) }
|
26
26
|
assert_equal 'Invalid key(s): invalid', exception.message
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
class BranchWithNoRequirementsTest < Test
|
30
|
+
class BranchWithNoRequirementsTest < MiniTest::Test
|
31
31
|
def setup
|
32
32
|
@object = Object.new
|
33
33
|
@branch = EnumStateMachine::Branch.new
|
@@ -62,7 +62,7 @@ class BranchWithNoRequirementsTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
class BranchWithFromRequirementTest < Test
|
65
|
+
class BranchWithFromRequirementTest < MiniTest::Test
|
66
66
|
def setup
|
67
67
|
@object = Object.new
|
68
68
|
@branch = EnumStateMachine::Branch.new(:from => :parked)
|
@@ -106,7 +106,7 @@ class BranchWithFromRequirementTest < Test::Unit::TestCase
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
class BranchWithMultipleFromRequirementsTest < Test
|
109
|
+
class BranchWithMultipleFromRequirementsTest < MiniTest::Test
|
110
110
|
def setup
|
111
111
|
@object = Object.new
|
112
112
|
@branch = EnumStateMachine::Branch.new(:from => [:idling, :parked])
|
@@ -125,7 +125,7 @@ class BranchWithMultipleFromRequirementsTest < Test::Unit::TestCase
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
class BranchWithFromMatcherRequirementTest < Test
|
128
|
+
class BranchWithFromMatcherRequirementTest < MiniTest::Test
|
129
129
|
def setup
|
130
130
|
@object = Object.new
|
131
131
|
@branch = EnumStateMachine::Branch.new(:from => EnumStateMachine::BlacklistMatcher.new([:idling, :parked]))
|
@@ -144,7 +144,7 @@ class BranchWithFromMatcherRequirementTest < Test::Unit::TestCase
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
class BranchWithToRequirementTest < Test
|
147
|
+
class BranchWithToRequirementTest < MiniTest::Test
|
148
148
|
def setup
|
149
149
|
@object = Object.new
|
150
150
|
@branch = EnumStateMachine::Branch.new(:to => :idling)
|
@@ -188,7 +188,7 @@ class BranchWithToRequirementTest < Test::Unit::TestCase
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
class BranchWithMultipleToRequirementsTest < Test
|
191
|
+
class BranchWithMultipleToRequirementsTest < MiniTest::Test
|
192
192
|
def setup
|
193
193
|
@object = Object.new
|
194
194
|
@branch = EnumStateMachine::Branch.new(:to => [:idling, :parked])
|
@@ -207,7 +207,7 @@ class BranchWithMultipleToRequirementsTest < Test::Unit::TestCase
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
-
class BranchWithToMatcherRequirementTest < Test
|
210
|
+
class BranchWithToMatcherRequirementTest < MiniTest::Test
|
211
211
|
def setup
|
212
212
|
@object = Object.new
|
213
213
|
@branch = EnumStateMachine::Branch.new(:to => EnumStateMachine::BlacklistMatcher.new([:idling, :parked]))
|
@@ -226,7 +226,7 @@ class BranchWithToMatcherRequirementTest < Test::Unit::TestCase
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
-
class BranchWithOnRequirementTest < Test
|
229
|
+
class BranchWithOnRequirementTest < MiniTest::Test
|
230
230
|
def setup
|
231
231
|
@object = Object.new
|
232
232
|
@branch = EnumStateMachine::Branch.new(:on => :ignite)
|
@@ -270,7 +270,7 @@ class BranchWithOnRequirementTest < Test::Unit::TestCase
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
class BranchWithMultipleOnRequirementsTest < Test
|
273
|
+
class BranchWithMultipleOnRequirementsTest < MiniTest::Test
|
274
274
|
def setup
|
275
275
|
@object = Object.new
|
276
276
|
@branch = EnumStateMachine::Branch.new(:on => [:ignite, :park])
|
@@ -285,7 +285,7 @@ class BranchWithMultipleOnRequirementsTest < Test::Unit::TestCase
|
|
285
285
|
end
|
286
286
|
end
|
287
287
|
|
288
|
-
class BranchWithOnMatcherRequirementTest < Test
|
288
|
+
class BranchWithOnMatcherRequirementTest < MiniTest::Test
|
289
289
|
def setup
|
290
290
|
@object = Object.new
|
291
291
|
@branch = EnumStateMachine::Branch.new(:on => EnumStateMachine::BlacklistMatcher.new([:ignite, :park]))
|
@@ -300,7 +300,7 @@ class BranchWithOnMatcherRequirementTest < Test::Unit::TestCase
|
|
300
300
|
end
|
301
301
|
end
|
302
302
|
|
303
|
-
class BranchWithExceptFromRequirementTest < Test
|
303
|
+
class BranchWithExceptFromRequirementTest < MiniTest::Test
|
304
304
|
def setup
|
305
305
|
@object = Object.new
|
306
306
|
@branch = EnumStateMachine::Branch.new(:except_from => :parked)
|
@@ -335,7 +335,7 @@ class BranchWithExceptFromRequirementTest < Test::Unit::TestCase
|
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
class BranchWithMultipleExceptFromRequirementsTest < Test
|
338
|
+
class BranchWithMultipleExceptFromRequirementsTest < MiniTest::Test
|
339
339
|
def setup
|
340
340
|
@object = Object.new
|
341
341
|
@branch = EnumStateMachine::Branch.new(:except_from => [:idling, :parked])
|
@@ -354,14 +354,16 @@ class BranchWithMultipleExceptFromRequirementsTest < Test::Unit::TestCase
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
-
class BranchWithExceptFromMatcherRequirementTest < Test
|
357
|
+
class BranchWithExceptFromMatcherRequirementTest < MiniTest::Test
|
358
358
|
def test_should_raise_an_exception
|
359
|
-
exception =
|
359
|
+
exception = assert_raises(ArgumentError) {
|
360
|
+
EnumStateMachine::Branch.new(:except_from => EnumStateMachine::AllMatcher.instance)
|
361
|
+
}
|
360
362
|
assert_equal ':except_from option cannot use matchers; use :from instead', exception.message
|
361
363
|
end
|
362
364
|
end
|
363
365
|
|
364
|
-
class BranchWithExceptToRequirementTest < Test
|
366
|
+
class BranchWithExceptToRequirementTest < MiniTest::Test
|
365
367
|
def setup
|
366
368
|
@object = Object.new
|
367
369
|
@branch = EnumStateMachine::Branch.new(:except_to => :idling)
|
@@ -396,7 +398,7 @@ class BranchWithExceptToRequirementTest < Test::Unit::TestCase
|
|
396
398
|
end
|
397
399
|
end
|
398
400
|
|
399
|
-
class BranchWithMultipleExceptToRequirementsTest < Test
|
401
|
+
class BranchWithMultipleExceptToRequirementsTest < MiniTest::Test
|
400
402
|
def setup
|
401
403
|
@object = Object.new
|
402
404
|
@branch = EnumStateMachine::Branch.new(:except_to => [:idling, :parked])
|
@@ -415,14 +417,16 @@ class BranchWithMultipleExceptToRequirementsTest < Test::Unit::TestCase
|
|
415
417
|
end
|
416
418
|
end
|
417
419
|
|
418
|
-
class BranchWithExceptToMatcherRequirementTest < Test
|
420
|
+
class BranchWithExceptToMatcherRequirementTest < MiniTest::Test
|
419
421
|
def test_should_raise_an_exception
|
420
|
-
exception =
|
422
|
+
exception = assert_raises(ArgumentError) {
|
423
|
+
EnumStateMachine::Branch.new(:except_to => EnumStateMachine::AllMatcher.instance)
|
424
|
+
}
|
421
425
|
assert_equal ':except_to option cannot use matchers; use :to instead', exception.message
|
422
426
|
end
|
423
427
|
end
|
424
428
|
|
425
|
-
class BranchWithExceptOnRequirementTest < Test
|
429
|
+
class BranchWithExceptOnRequirementTest < MiniTest::Test
|
426
430
|
def setup
|
427
431
|
@object = Object.new
|
428
432
|
@branch = EnumStateMachine::Branch.new(:except_on => :ignite)
|
@@ -457,14 +461,16 @@ class BranchWithExceptOnRequirementTest < Test::Unit::TestCase
|
|
457
461
|
end
|
458
462
|
end
|
459
463
|
|
460
|
-
class BranchWithExceptOnMatcherRequirementTest < Test
|
464
|
+
class BranchWithExceptOnMatcherRequirementTest < MiniTest::Test
|
461
465
|
def test_should_raise_an_exception
|
462
|
-
exception =
|
466
|
+
exception = assert_raises(ArgumentError) {
|
467
|
+
EnumStateMachine::Branch.new(:except_on => EnumStateMachine::AllMatcher.instance)
|
468
|
+
}
|
463
469
|
assert_equal ':except_on option cannot use matchers; use :on instead', exception.message
|
464
470
|
end
|
465
471
|
end
|
466
472
|
|
467
|
-
class BranchWithMultipleExceptOnRequirementsTest < Test
|
473
|
+
class BranchWithMultipleExceptOnRequirementsTest < MiniTest::Test
|
468
474
|
def setup
|
469
475
|
@object = Object.new
|
470
476
|
@branch = EnumStateMachine::Branch.new(:except_on => [:ignite, :park])
|
@@ -479,28 +485,34 @@ class BranchWithMultipleExceptOnRequirementsTest < Test::Unit::TestCase
|
|
479
485
|
end
|
480
486
|
end
|
481
487
|
|
482
|
-
class BranchWithConflictingFromRequirementsTest < Test
|
488
|
+
class BranchWithConflictingFromRequirementsTest < MiniTest::Test
|
483
489
|
def test_should_raise_an_exception
|
484
|
-
exception =
|
490
|
+
exception = assert_raises(ArgumentError) {
|
491
|
+
EnumStateMachine::Branch.new(:from => :parked, :except_from => :parked)
|
492
|
+
}
|
485
493
|
assert_equal 'Conflicting keys: from, except_from', exception.message
|
486
494
|
end
|
487
495
|
end
|
488
496
|
|
489
|
-
class BranchWithConflictingToRequirementsTest < Test
|
497
|
+
class BranchWithConflictingToRequirementsTest < MiniTest::Test
|
490
498
|
def test_should_raise_an_exception
|
491
|
-
exception =
|
499
|
+
exception = assert_raises(ArgumentError) {
|
500
|
+
EnumStateMachine::Branch.new(:to => :idling, :except_to => :idling)
|
501
|
+
}
|
492
502
|
assert_equal 'Conflicting keys: to, except_to', exception.message
|
493
503
|
end
|
494
504
|
end
|
495
505
|
|
496
|
-
class BranchWithConflictingOnRequirementsTest < Test
|
506
|
+
class BranchWithConflictingOnRequirementsTest < MiniTest::Test
|
497
507
|
def test_should_raise_an_exception
|
498
|
-
exception =
|
508
|
+
exception = assert_raises(ArgumentError) {
|
509
|
+
EnumStateMachine::Branch.new(:on => :ignite, :except_on => :ignite)
|
510
|
+
}
|
499
511
|
assert_equal 'Conflicting keys: on, except_on', exception.message
|
500
512
|
end
|
501
513
|
end
|
502
514
|
|
503
|
-
class BranchWithDifferentRequirementsTest < Test
|
515
|
+
class BranchWithDifferentRequirementsTest < MiniTest::Test
|
504
516
|
def setup
|
505
517
|
@object = Object.new
|
506
518
|
@branch = EnumStateMachine::Branch.new(:from => :parked, :to => :idling, :on => :ignite)
|
@@ -540,7 +552,7 @@ class BranchWithDifferentRequirementsTest < Test::Unit::TestCase
|
|
540
552
|
end
|
541
553
|
end
|
542
554
|
|
543
|
-
class BranchWithNilRequirementsTest < Test
|
555
|
+
class BranchWithNilRequirementsTest < MiniTest::Test
|
544
556
|
def setup
|
545
557
|
@object = Object.new
|
546
558
|
@branch = EnumStateMachine::Branch.new(:from => nil, :to => nil)
|
@@ -567,7 +579,7 @@ class BranchWithNilRequirementsTest < Test::Unit::TestCase
|
|
567
579
|
end
|
568
580
|
end
|
569
581
|
|
570
|
-
class BranchWithImplicitRequirementTest < Test
|
582
|
+
class BranchWithImplicitRequirementTest < MiniTest::Test
|
571
583
|
def setup
|
572
584
|
@branch = EnumStateMachine::Branch.new(:parked => :idling, :on => :ignite)
|
573
585
|
end
|
@@ -586,7 +598,7 @@ class BranchWithImplicitRequirementTest < Test::Unit::TestCase
|
|
586
598
|
end
|
587
599
|
end
|
588
600
|
|
589
|
-
class BranchWithMultipleImplicitRequirementsTest < Test
|
601
|
+
class BranchWithMultipleImplicitRequirementsTest < MiniTest::Test
|
590
602
|
def setup
|
591
603
|
@object = Object.new
|
592
604
|
@branch = EnumStateMachine::Branch.new(:parked => :idling, :idling => :first_gear, :on => :ignite)
|
@@ -638,7 +650,7 @@ class BranchWithMultipleImplicitRequirementsTest < Test::Unit::TestCase
|
|
638
650
|
end
|
639
651
|
end
|
640
652
|
|
641
|
-
class BranchWithImplicitFromRequirementMatcherTest < Test
|
653
|
+
class BranchWithImplicitFromRequirementMatcherTest < MiniTest::Test
|
642
654
|
def setup
|
643
655
|
@matcher = EnumStateMachine::BlacklistMatcher.new(:parked)
|
644
656
|
@branch = EnumStateMachine::Branch.new(@matcher => :idling)
|
@@ -653,7 +665,7 @@ class BranchWithImplicitFromRequirementMatcherTest < Test::Unit::TestCase
|
|
653
665
|
end
|
654
666
|
end
|
655
667
|
|
656
|
-
class BranchWithImplicitToRequirementMatcherTest < Test
|
668
|
+
class BranchWithImplicitToRequirementMatcherTest < MiniTest::Test
|
657
669
|
def setup
|
658
670
|
@matcher = EnumStateMachine::BlacklistMatcher.new(:idling)
|
659
671
|
@branch = EnumStateMachine::Branch.new(:parked => @matcher)
|
@@ -668,7 +680,7 @@ class BranchWithImplicitToRequirementMatcherTest < Test::Unit::TestCase
|
|
668
680
|
end
|
669
681
|
end
|
670
682
|
|
671
|
-
class BranchWithImplicitAndExplicitRequirementsTest < Test
|
683
|
+
class BranchWithImplicitAndExplicitRequirementsTest < MiniTest::Test
|
672
684
|
def setup
|
673
685
|
@branch = EnumStateMachine::Branch.new(:parked => :idling, :from => :parked)
|
674
686
|
end
|
@@ -690,14 +702,14 @@ class BranchWithImplicitAndExplicitRequirementsTest < Test::Unit::TestCase
|
|
690
702
|
end
|
691
703
|
end
|
692
704
|
|
693
|
-
class BranchWithIfConditionalTest < Test
|
705
|
+
class BranchWithIfConditionalTest < MiniTest::Test
|
694
706
|
def setup
|
695
707
|
@object = Object.new
|
696
708
|
end
|
697
709
|
|
698
710
|
def test_should_have_an_if_condition
|
699
711
|
branch = EnumStateMachine::Branch.new(:if => lambda {true})
|
700
|
-
|
712
|
+
refute_nil branch.if_condition
|
701
713
|
end
|
702
714
|
|
703
715
|
def test_should_match_if_true
|
@@ -716,7 +728,7 @@ class BranchWithIfConditionalTest < Test::Unit::TestCase
|
|
716
728
|
end
|
717
729
|
end
|
718
730
|
|
719
|
-
class BranchWithMultipleIfConditionalsTest < Test
|
731
|
+
class BranchWithMultipleIfConditionalsTest < MiniTest::Test
|
720
732
|
def setup
|
721
733
|
@object = Object.new
|
722
734
|
end
|
@@ -735,14 +747,14 @@ class BranchWithMultipleIfConditionalsTest < Test::Unit::TestCase
|
|
735
747
|
end
|
736
748
|
end
|
737
749
|
|
738
|
-
class BranchWithUnlessConditionalTest < Test
|
750
|
+
class BranchWithUnlessConditionalTest < MiniTest::Test
|
739
751
|
def setup
|
740
752
|
@object = Object.new
|
741
753
|
end
|
742
754
|
|
743
755
|
def test_should_have_an_unless_condition
|
744
756
|
branch = EnumStateMachine::Branch.new(:unless => lambda {true})
|
745
|
-
|
757
|
+
refute_nil branch.unless_condition
|
746
758
|
end
|
747
759
|
|
748
760
|
def test_should_match_if_false
|
@@ -761,7 +773,7 @@ class BranchWithUnlessConditionalTest < Test::Unit::TestCase
|
|
761
773
|
end
|
762
774
|
end
|
763
775
|
|
764
|
-
class BranchWithMultipleUnlessConditionalsTest < Test
|
776
|
+
class BranchWithMultipleUnlessConditionalsTest < MiniTest::Test
|
765
777
|
def setup
|
766
778
|
@object = Object.new
|
767
779
|
end
|
@@ -780,7 +792,7 @@ class BranchWithMultipleUnlessConditionalsTest < Test::Unit::TestCase
|
|
780
792
|
end
|
781
793
|
end
|
782
794
|
|
783
|
-
class BranchWithConflictingConditionalsTest < Test
|
795
|
+
class BranchWithConflictingConditionalsTest < MiniTest::Test
|
784
796
|
def setup
|
785
797
|
@object = Object.new
|
786
798
|
end
|
@@ -806,7 +818,7 @@ class BranchWithConflictingConditionalsTest < Test::Unit::TestCase
|
|
806
818
|
end
|
807
819
|
end
|
808
820
|
|
809
|
-
class BranchWithoutGuardsTest < Test
|
821
|
+
class BranchWithoutGuardsTest < MiniTest::Test
|
810
822
|
def setup
|
811
823
|
@object = Object.new
|
812
824
|
end
|
@@ -836,7 +848,7 @@ begin
|
|
836
848
|
# Load library
|
837
849
|
require 'graphviz'
|
838
850
|
|
839
|
-
class BranchDrawingTest < Test
|
851
|
+
class BranchDrawingTest < MiniTest::Test
|
840
852
|
def setup
|
841
853
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
842
854
|
states = [:parked, :idling]
|
@@ -866,7 +878,7 @@ begin
|
|
866
878
|
end
|
867
879
|
end
|
868
880
|
|
869
|
-
class BranchDrawingWithFromRequirementTest < Test
|
881
|
+
class BranchDrawingWithFromRequirementTest < MiniTest::Test
|
870
882
|
def setup
|
871
883
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
872
884
|
states = [:parked, :idling, :first_gear]
|
@@ -887,7 +899,7 @@ begin
|
|
887
899
|
end
|
888
900
|
end
|
889
901
|
|
890
|
-
class BranchDrawingWithExceptFromRequirementTest < Test
|
902
|
+
class BranchDrawingWithExceptFromRequirementTest < MiniTest::Test
|
891
903
|
def setup
|
892
904
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
893
905
|
states = [:parked, :idling, :first_gear]
|
@@ -908,7 +920,7 @@ begin
|
|
908
920
|
end
|
909
921
|
end
|
910
922
|
|
911
|
-
class BranchDrawingWithoutFromRequirementTest < Test
|
923
|
+
class BranchDrawingWithoutFromRequirementTest < MiniTest::Test
|
912
924
|
def setup
|
913
925
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
914
926
|
states = [:parked, :idling, :first_gear]
|
@@ -929,7 +941,7 @@ begin
|
|
929
941
|
end
|
930
942
|
end
|
931
943
|
|
932
|
-
class BranchDrawingWithoutToRequirementTest < Test
|
944
|
+
class BranchDrawingWithoutToRequirementTest < MiniTest::Test
|
933
945
|
def setup
|
934
946
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
935
947
|
|
@@ -947,7 +959,7 @@ begin
|
|
947
959
|
end
|
948
960
|
end
|
949
961
|
|
950
|
-
class BranchDrawingWithNilStateTest < Test
|
962
|
+
class BranchDrawingWithNilStateTest < MiniTest::Test
|
951
963
|
def setup
|
952
964
|
@machine = EnumStateMachine::Machine.new(Class.new)
|
953
965
|
|
@@ -965,5 +977,6 @@ begin
|
|
965
977
|
end
|
966
978
|
end
|
967
979
|
rescue LoadError
|
968
|
-
$stderr.puts 'Skipping GraphViz EnumStateMachine::Branch tests.
|
980
|
+
$stderr.puts 'Skipping GraphViz EnumStateMachine::Branch tests. ' \
|
981
|
+
'`gem install ruby-graphviz` >= v0.9.17 and try again.'
|
969
982
|
end unless ENV['TRAVIS']
|
data/test/unit/callback_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class CallbackTest < Test
|
3
|
+
class CallbackTest < MiniTest::Test
|
4
4
|
def test_should_raise_exception_if_invalid_type_specified
|
5
|
-
exception =
|
5
|
+
exception = assert_raises(ArgumentError) { EnumStateMachine::Callback.new(:invalid) {} }
|
6
6
|
assert_equal 'Type must be :before, :after, :around, or :failure', exception.message
|
7
7
|
end
|
8
8
|
|
@@ -23,7 +23,7 @@ class CallbackTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_raise_exception_if_no_methods_specified
|
26
|
-
exception =
|
26
|
+
exception = assert_raises(ArgumentError) { EnumStateMachine::Callback.new(:before) }
|
27
27
|
assert_equal 'Method(s) for callback must be specified', exception.message
|
28
28
|
end
|
29
29
|
|
@@ -52,7 +52,7 @@ class CallbackTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
class CallbackByDefaultTest < Test
|
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 < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
class CallbackWithMethodArgumentTest < Test
|
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 < Test::Unit::TestCase
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
class CallbackWithMultipleMethodArgumentsTest < Test
|
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 < Test::Unit::TestCase
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
class CallbackWithDoMethodTest < Test
|
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 < Test::Unit::TestCase
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
class CallbackWithMultipleDoMethodsTest < Test
|
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 < Test::Unit::TestCase
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
-
class CallbackWithBlockTest < Test
|
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 < Test::Unit::TestCase
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
-
class CallbackWithMixedMethodsTest < Test
|
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 < Test::Unit::TestCase
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
class CallbackWithExplicitRequirementsTest < Test
|
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 < Test::Unit::TestCase
|
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
|
-
class CallbackWithImplicitRequirementsTest < Test
|
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 < Test::Unit::TestCase
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
-
class CallbackWithIfConditionTest < Test
|
280
|
+
class CallbackWithIfConditionTest < MiniTest::Test
|
281
281
|
def setup
|
282
282
|
@object = Object.new
|
283
283
|
end
|
@@ -293,7 +293,7 @@ class CallbackWithIfConditionTest < Test::Unit::TestCase
|
|
293
293
|
end
|
294
294
|
end
|
295
295
|
|
296
|
-
class CallbackWithUnlessConditionTest < Test
|
296
|
+
class CallbackWithUnlessConditionTest < MiniTest::Test
|
297
297
|
def setup
|
298
298
|
@object = Object.new
|
299
299
|
end
|
@@ -309,7 +309,7 @@ class CallbackWithUnlessConditionTest < Test::Unit::TestCase
|
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
class CallbackWithoutTerminatorTest < Test
|
312
|
+
class CallbackWithoutTerminatorTest < MiniTest::Test
|
313
313
|
def setup
|
314
314
|
@object = Object.new
|
315
315
|
end
|
@@ -320,7 +320,7 @@ class CallbackWithoutTerminatorTest < Test::Unit::TestCase
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
|
323
|
-
class CallbackWithTerminatorTest < Test
|
323
|
+
class CallbackWithTerminatorTest < MiniTest::Test
|
324
324
|
def setup
|
325
325
|
@object = Object.new
|
326
326
|
end
|
@@ -341,7 +341,7 @@ class CallbackWithTerminatorTest < Test::Unit::TestCase
|
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
class CallbackWithoutArgumentsTest < Test
|
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 < Test::Unit::TestCase
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
-
class CallbackWithArgumentsTest < Test
|
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 < Test::Unit::TestCase
|
|
367
367
|
end
|
368
368
|
end
|
369
369
|
|
370
|
-
class CallbackWithUnboundMethodTest < Test
|
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 < Test::Unit::TestCase
|
|
380
380
|
end
|
381
381
|
end
|
382
382
|
|
383
|
-
class CallbackWithBoundMethodTest < Test
|
383
|
+
class CallbackWithBoundMethodTest < MiniTest::Test
|
384
384
|
def setup
|
385
385
|
@object = Object.new
|
386
386
|
end
|
@@ -414,7 +414,7 @@ class CallbackWithBoundMethodTest < Test::Unit::TestCase
|
|
414
414
|
end
|
415
415
|
end
|
416
416
|
|
417
|
-
class CallbackWithMultipleBoundMethodsTest < Test
|
417
|
+
class CallbackWithMultipleBoundMethodsTest < MiniTest::Test
|
418
418
|
def setup
|
419
419
|
@object = Object.new
|
420
420
|
|
@@ -434,7 +434,7 @@ class CallbackWithMultipleBoundMethodsTest < Test::Unit::TestCase
|
|
434
434
|
end
|
435
435
|
end
|
436
436
|
|
437
|
-
class CallbackWithApplicationBoundObjectTest < Test
|
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 < Test::Unit::TestCase
|
|
456
456
|
end
|
457
457
|
end
|
458
458
|
|
459
|
-
class CallbackWithBoundMethodAndArgumentsTest < Test
|
459
|
+
class CallbackWithBoundMethodAndArgumentsTest < MiniTest::Test
|
460
460
|
def setup
|
461
461
|
@object = Object.new
|
462
462
|
end
|
@@ -483,7 +483,7 @@ class CallbackWithBoundMethodAndArgumentsTest < Test::Unit::TestCase
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
class CallbackWithApplicationTerminatorTest < Test
|
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 < Test::Unit::TestCase
|
|
506
506
|
end
|
507
507
|
end
|
508
508
|
|
509
|
-
class CallbackWithAroundTypeAndBlockTest < Test
|
509
|
+
class CallbackWithAroundTypeAndBlockTest < MiniTest::Test
|
510
510
|
def setup
|
511
511
|
@object = Object.new
|
512
512
|
@callbacks = []
|
@@ -549,7 +549,7 @@ class CallbackWithAroundTypeAndBlockTest < Test::Unit::TestCase
|
|
549
549
|
end
|
550
550
|
end
|
551
551
|
|
552
|
-
class CallbackWithAroundTypeAndMultipleMethodsTest < Test
|
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 < Test::Unit::TestCase
|
|
641
641
|
end
|
642
642
|
end
|
643
643
|
|
644
|
-
class CallbackWithAroundTypeAndArgumentsTest < Test
|
644
|
+
class CallbackWithAroundTypeAndArgumentsTest < MiniTest::Test
|
645
645
|
def setup
|
646
646
|
@object = Object.new
|
647
647
|
end
|
@@ -665,7 +665,7 @@ class CallbackWithAroundTypeAndArgumentsTest < Test::Unit::TestCase
|
|
665
665
|
end
|
666
666
|
end
|
667
667
|
|
668
|
-
class CallbackWithAroundTypeAndTerminatorTest < Test
|
668
|
+
class CallbackWithAroundTypeAndTerminatorTest < MiniTest::Test
|
669
669
|
def setup
|
670
670
|
@object = Object.new
|
671
671
|
end
|
@@ -681,7 +681,7 @@ class CallbackWithAroundTypeAndTerminatorTest < Test::Unit::TestCase
|
|
681
681
|
end
|
682
682
|
end
|
683
683
|
|
684
|
-
class CallbackWithAroundTypeAndBoundMethodTest < Test
|
684
|
+
class CallbackWithAroundTypeAndBoundMethodTest < MiniTest::Test
|
685
685
|
def setup
|
686
686
|
@object = Object.new
|
687
687
|
end
|