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
|
@@ -450,7 +450,7 @@ module ActiveRecordTest
|
|
|
450
450
|
|
|
451
451
|
class MachineWithSameColumnDefaultTest < BaseTestCase
|
|
452
452
|
def setup
|
|
453
|
-
@
|
|
453
|
+
set_rails_logger(@io = StringIO.new)
|
|
454
454
|
|
|
455
455
|
@model = new_model do
|
|
456
456
|
connection.add_column table_name, :status, :string, :default => 'parked'
|
|
@@ -464,18 +464,18 @@ module ActiveRecordTest
|
|
|
464
464
|
end
|
|
465
465
|
|
|
466
466
|
def test_should_not_generate_a_warning
|
|
467
|
-
assert_no_match(/have defined a different default/,
|
|
467
|
+
assert_no_match(/have defined a different default/, @io.string)
|
|
468
468
|
end
|
|
469
469
|
|
|
470
470
|
def teardown
|
|
471
|
-
|
|
471
|
+
reset_rails_logger
|
|
472
472
|
super
|
|
473
473
|
end
|
|
474
474
|
end
|
|
475
475
|
|
|
476
476
|
class MachineWithDifferentColumnDefaultTest < BaseTestCase
|
|
477
477
|
def setup
|
|
478
|
-
@
|
|
478
|
+
set_rails_logger(@io = StringIO.new)
|
|
479
479
|
|
|
480
480
|
@model = new_model do
|
|
481
481
|
connection.add_column table_name, :status, :string, :default => 'idling'
|
|
@@ -489,18 +489,18 @@ module ActiveRecordTest
|
|
|
489
489
|
end
|
|
490
490
|
|
|
491
491
|
def test_should_generate_a_warning
|
|
492
|
-
assert_match(/Both ActiveRecordTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./,
|
|
492
|
+
assert_match(/Both ActiveRecordTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, @io.string)
|
|
493
493
|
end
|
|
494
494
|
|
|
495
495
|
def teardown
|
|
496
|
-
|
|
496
|
+
reset_rails_logger
|
|
497
497
|
super
|
|
498
498
|
end
|
|
499
499
|
end
|
|
500
500
|
|
|
501
501
|
class MachineWithDifferentIntegerColumnDefaultTest < BaseTestCase
|
|
502
502
|
def setup
|
|
503
|
-
@
|
|
503
|
+
set_rails_logger(@io = StringIO.new)
|
|
504
504
|
|
|
505
505
|
@model = new_model do
|
|
506
506
|
connection.add_column table_name, :status, :integer, :default => 0
|
|
@@ -515,11 +515,11 @@ module ActiveRecordTest
|
|
|
515
515
|
end
|
|
516
516
|
|
|
517
517
|
def test_should_generate_a_warning
|
|
518
|
-
assert_match(/Both ActiveRecordTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./,
|
|
518
|
+
assert_match(/Both ActiveRecordTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, @io.string)
|
|
519
519
|
end
|
|
520
520
|
|
|
521
521
|
def teardown
|
|
522
|
-
|
|
522
|
+
reset_rails_logger
|
|
523
523
|
super
|
|
524
524
|
end
|
|
525
525
|
end
|
|
@@ -544,7 +544,7 @@ module ActiveRecordTest
|
|
|
544
544
|
class MachineWithConflictingStateNameTest < BaseTestCase
|
|
545
545
|
def setup
|
|
546
546
|
require 'stringio'
|
|
547
|
-
@
|
|
547
|
+
set_rails_logger(@io = StringIO.new)
|
|
548
548
|
|
|
549
549
|
@model = new_model
|
|
550
550
|
end
|
|
@@ -553,18 +553,18 @@ module ActiveRecordTest
|
|
|
553
553
|
@machine = EnumStateMachine::Machine.new(@model)
|
|
554
554
|
@machine.state :state
|
|
555
555
|
|
|
556
|
-
assert_match(/^Instance method "state\?" is already defined in ActiveRecordTest::Foo, use generic helper instead.*\n$/,
|
|
556
|
+
assert_match(/^Instance method "state\?" is already defined in ActiveRecordTest::Foo, use generic helper instead.*\n$/, @io.string)
|
|
557
557
|
end
|
|
558
558
|
|
|
559
559
|
def test_should_output_warning_with_same_machine_attribute
|
|
560
560
|
@machine = EnumStateMachine::Machine.new(@model, :public_state, :attribute => :state)
|
|
561
561
|
@machine.state :state
|
|
562
562
|
|
|
563
|
-
assert_match(/^Instance method "state\?" is already defined in ActiveRecordTest::Foo, use generic helper instead.*\n$/,
|
|
563
|
+
assert_match(/^Instance method "state\?" is already defined in ActiveRecordTest::Foo, use generic helper instead.*\n$/, @io.string)
|
|
564
564
|
end
|
|
565
565
|
|
|
566
566
|
def teardown
|
|
567
|
-
|
|
567
|
+
reset_rails_logger
|
|
568
568
|
super
|
|
569
569
|
end
|
|
570
570
|
end
|
|
@@ -702,7 +702,7 @@ module ActiveRecordTest
|
|
|
702
702
|
class MachineWithCustomAttributeTest < BaseTestCase
|
|
703
703
|
def setup
|
|
704
704
|
require 'stringio'
|
|
705
|
-
@
|
|
705
|
+
set_rails_logger(@io = StringIO.new)
|
|
706
706
|
|
|
707
707
|
@model = new_model
|
|
708
708
|
@machine = EnumStateMachine::Machine.new(@model, :public_state, :attribute => :state)
|
|
@@ -714,7 +714,7 @@ module ActiveRecordTest
|
|
|
714
714
|
end
|
|
715
715
|
|
|
716
716
|
def teardown
|
|
717
|
-
|
|
717
|
+
reset_rails_logger
|
|
718
718
|
super
|
|
719
719
|
end
|
|
720
720
|
end
|
|
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
|
|
4
4
|
require 'rubygems'
|
|
5
5
|
|
|
6
6
|
module BaseTest
|
|
7
|
-
class IntegrationTest <
|
|
7
|
+
class IntegrationTest < Minitest::Test
|
|
8
8
|
def test_should_have_an_integration_name
|
|
9
9
|
assert_equal :base, EnumStateMachine::Integrations::Base.integration_name
|
|
10
10
|
end
|
|
@@ -26,7 +26,7 @@ module BaseTest
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
class IncludedTest <
|
|
29
|
+
class IncludedTest < Minitest::Test
|
|
30
30
|
def setup
|
|
31
31
|
@integration = Module.new
|
|
32
32
|
EnumStateMachine::Integrations.const_set('Custom', @integration)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
2
2
|
|
|
3
|
-
class IntegrationMatcherTest <
|
|
3
|
+
class IntegrationMatcherTest < Minitest::Test
|
|
4
4
|
def setup
|
|
5
5
|
superclass = Class.new
|
|
6
6
|
self.class.const_set('Vehicle', superclass)
|
|
@@ -51,7 +51,7 @@ class IntegrationMatcherTest < MiniTest::Test
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
class IntegrationFinderTest <
|
|
54
|
+
class IntegrationFinderTest < Minitest::Test
|
|
55
55
|
def test_should_find_base
|
|
56
56
|
assert_equal EnumStateMachine::Integrations::Base, EnumStateMachine::Integrations.find_by_name(:base)
|
|
57
57
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
2
2
|
|
|
3
|
-
class InvalidTransitionTest <
|
|
3
|
+
class InvalidTransitionTest < Minitest::Test
|
|
4
4
|
def setup
|
|
5
5
|
@klass = Class.new
|
|
6
6
|
@machine = EnumStateMachine::Machine.new(@klass)
|
|
@@ -46,7 +46,7 @@ class InvalidTransitionTest < MiniTest::Test
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
class InvalidTransitionWithNamespaceTest <
|
|
49
|
+
class InvalidTransitionWithNamespaceTest < Minitest::Test
|
|
50
50
|
def setup
|
|
51
51
|
@klass = Class.new
|
|
52
52
|
@machine = EnumStateMachine::Machine.new(@klass, :namespace => 'alarm')
|
|
@@ -76,7 +76,7 @@ class InvalidTransitionWithNamespaceTest < MiniTest::Test
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
class InvalidTransitionWithIntegrationTest <
|
|
79
|
+
class InvalidTransitionWithIntegrationTest < Minitest::Test
|
|
80
80
|
def setup
|
|
81
81
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
|
82
82
|
include EnumStateMachine::Integrations::Base
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
|
2
2
|
|
|
3
|
-
class MachineCollectionByDefaultTest <
|
|
3
|
+
class MachineCollectionByDefaultTest < Minitest::Test
|
|
4
4
|
def setup
|
|
5
5
|
@machines = EnumStateMachine::MachineCollection.new
|
|
6
6
|
end
|
|
@@ -10,7 +10,7 @@ class MachineCollectionByDefaultTest < MiniTest::Test
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
class MachineCollectionStateInitializationTest <
|
|
13
|
+
class MachineCollectionStateInitializationTest < Minitest::Test
|
|
14
14
|
def setup
|
|
15
15
|
@machines = EnumStateMachine::MachineCollection.new
|
|
16
16
|
|
|
@@ -110,7 +110,7 @@ class MachineCollectionStateInitializationTest < MiniTest::Test
|
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
class MachineCollectionFireTest <
|
|
113
|
+
class MachineCollectionFireTest < Minitest::Test
|
|
114
114
|
def setup
|
|
115
115
|
@machines = EnumStateMachine::MachineCollection.new
|
|
116
116
|
|
|
@@ -193,7 +193,7 @@ class MachineCollectionFireTest < MiniTest::Test
|
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
class MachineCollectionFireWithTransactionsTest <
|
|
196
|
+
class MachineCollectionFireWithTransactionsTest < Minitest::Test
|
|
197
197
|
def setup
|
|
198
198
|
@machines = EnumStateMachine::MachineCollection.new
|
|
199
199
|
|
|
@@ -267,7 +267,7 @@ class MachineCollectionFireWithTransactionsTest < MiniTest::Test
|
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
269
|
|
|
270
|
-
class MachineCollectionFireWithValidationsTest <
|
|
270
|
+
class MachineCollectionFireWithValidationsTest < Minitest::Test
|
|
271
271
|
def setup
|
|
272
272
|
EnumStateMachine::Integrations.const_set('Custom', Module.new do
|
|
273
273
|
include EnumStateMachine::Integrations::Base
|
|
@@ -335,7 +335,7 @@ class MachineCollectionFireWithValidationsTest < MiniTest::Test
|
|
|
335
335
|
end
|
|
336
336
|
end
|
|
337
337
|
|
|
338
|
-
class MachineCollectionTransitionsWithoutEventsTest <
|
|
338
|
+
class MachineCollectionTransitionsWithoutEventsTest < Minitest::Test
|
|
339
339
|
def setup
|
|
340
340
|
@klass = Class.new
|
|
341
341
|
|
|
@@ -359,7 +359,7 @@ class MachineCollectionTransitionsWithoutEventsTest < MiniTest::Test
|
|
|
359
359
|
end
|
|
360
360
|
end
|
|
361
361
|
|
|
362
|
-
class MachineCollectionTransitionsWithBlankEventsTest <
|
|
362
|
+
class MachineCollectionTransitionsWithBlankEventsTest < Minitest::Test
|
|
363
363
|
def setup
|
|
364
364
|
@klass = Class.new
|
|
365
365
|
|
|
@@ -383,7 +383,7 @@ class MachineCollectionTransitionsWithBlankEventsTest < MiniTest::Test
|
|
|
383
383
|
end
|
|
384
384
|
end
|
|
385
385
|
|
|
386
|
-
class MachineCollectionTransitionsWithInvalidEventsTest <
|
|
386
|
+
class MachineCollectionTransitionsWithInvalidEventsTest < Minitest::Test
|
|
387
387
|
def setup
|
|
388
388
|
@klass = Class.new
|
|
389
389
|
|
|
@@ -407,7 +407,7 @@ class MachineCollectionTransitionsWithInvalidEventsTest < MiniTest::Test
|
|
|
407
407
|
end
|
|
408
408
|
end
|
|
409
409
|
|
|
410
|
-
class MachineCollectionTransitionsWithoutTransitionTest <
|
|
410
|
+
class MachineCollectionTransitionsWithoutTransitionTest < Minitest::Test
|
|
411
411
|
def setup
|
|
412
412
|
@klass = Class.new
|
|
413
413
|
|
|
@@ -432,7 +432,7 @@ class MachineCollectionTransitionsWithoutTransitionTest < MiniTest::Test
|
|
|
432
432
|
end
|
|
433
433
|
end
|
|
434
434
|
|
|
435
|
-
class MachineCollectionTransitionsWithTransitionTest <
|
|
435
|
+
class MachineCollectionTransitionsWithTransitionTest < Minitest::Test
|
|
436
436
|
def setup
|
|
437
437
|
@klass = Class.new
|
|
438
438
|
|
|
@@ -456,7 +456,7 @@ class MachineCollectionTransitionsWithTransitionTest < MiniTest::Test
|
|
|
456
456
|
end
|
|
457
457
|
end
|
|
458
458
|
|
|
459
|
-
class MachineCollectionTransitionsWithSameActionsTest <
|
|
459
|
+
class MachineCollectionTransitionsWithSameActionsTest < Minitest::Test
|
|
460
460
|
def setup
|
|
461
461
|
@klass = Class.new
|
|
462
462
|
|
|
@@ -485,7 +485,7 @@ class MachineCollectionTransitionsWithSameActionsTest < MiniTest::Test
|
|
|
485
485
|
end
|
|
486
486
|
end
|
|
487
487
|
|
|
488
|
-
class MachineCollectionTransitionsWithDifferentActionsTest <
|
|
488
|
+
class MachineCollectionTransitionsWithDifferentActionsTest < Minitest::Test
|
|
489
489
|
def setup
|
|
490
490
|
@klass = Class.new
|
|
491
491
|
|
|
@@ -510,7 +510,7 @@ class MachineCollectionTransitionsWithDifferentActionsTest < MiniTest::Test
|
|
|
510
510
|
end
|
|
511
511
|
end
|
|
512
512
|
|
|
513
|
-
class MachineCollectionTransitionsWithExisitingTransitionsTest <
|
|
513
|
+
class MachineCollectionTransitionsWithExisitingTransitionsTest < Minitest::Test
|
|
514
514
|
def setup
|
|
515
515
|
@klass = Class.new
|
|
516
516
|
|
|
@@ -534,7 +534,7 @@ class MachineCollectionTransitionsWithExisitingTransitionsTest < MiniTest::Test
|
|
|
534
534
|
end
|
|
535
535
|
end
|
|
536
536
|
|
|
537
|
-
class MachineCollectionTransitionsWithCustomOptionsTest <
|
|
537
|
+
class MachineCollectionTransitionsWithCustomOptionsTest < Minitest::Test
|
|
538
538
|
def setup
|
|
539
539
|
@klass = Class.new
|
|
540
540
|
|
|
@@ -553,7 +553,7 @@ class MachineCollectionTransitionsWithCustomOptionsTest < MiniTest::Test
|
|
|
553
553
|
end
|
|
554
554
|
end
|
|
555
555
|
|
|
556
|
-
class MachineCollectionFireAttributesWithValidationsTest <
|
|
556
|
+
class MachineCollectionFireAttributesWithValidationsTest < Minitest::Test
|
|
557
557
|
def setup
|
|
558
558
|
@klass = Class.new do
|
|
559
559
|
attr_accessor :errors
|