enum_state_machine 0.1.1 → 0.2.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/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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71e6b42441dcc75052d13fa17238af8ae8528e88
|
4
|
+
data.tar.gz: bb40a059b58ce675d7e5e51cd1885a73f3d43780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca5e94e9e546fd839512dfe2f539a87b89ef06bfd0bb1302ce096a60b4ac468a47514d0c704b497d852b19ebcbbc94d497b0aebb6ceb31d6cebb169481eb9bf
|
7
|
+
data.tar.gz: a77f9f4cf047ec6646e171580200fc66590f4592333b1a5c4c0b735fae1737ee7249f0b6b7694ff0e05d9d40d9e758bb7a0a86f002c9746353c89da97023cc1d
|
data/enum_state_machine.gemspec
CHANGED
@@ -17,19 +17,17 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.extra_rdoc_files = %w(README.md CHANGELOG.md LICENSE)
|
18
18
|
s.license = 'MIT'
|
19
19
|
|
20
|
-
s.add_dependency "rails", "~> 4.0.
|
20
|
+
s.add_dependency "rails", "~> 4.0", "< 4.2"
|
21
21
|
|
22
|
-
s.add_dependency "activemodel", "~> 4.0.5"
|
23
|
-
s.add_dependency "activerecord", "~> 4.0.5"
|
24
22
|
s.add_dependency "activerecord-deprecated_finders", "~> 1.0.3"
|
25
23
|
s.add_dependency "protected_attributes", "~> 1.0.7"
|
26
|
-
s.add_dependency "rails-observers", "~> 0.1.2"
|
24
|
+
#s.add_dependency "rails-observers", "~> 0.1.2"
|
27
25
|
s.add_dependency "power_enum", "~> 2.7"
|
28
26
|
|
29
27
|
s.add_development_dependency "rake"
|
30
|
-
s.add_development_dependency "minitest", "~>
|
28
|
+
s.add_development_dependency "minitest", "~> 5.1"
|
31
29
|
s.add_development_dependency "simplecov"
|
32
30
|
s.add_development_dependency "yard"
|
33
31
|
s.add_development_dependency "sqlite3", "~> 1.3.9"
|
34
|
-
s.add_development_dependency "ruby-graphviz"
|
32
|
+
s.add_development_dependency "ruby-graphviz"
|
35
33
|
end
|
@@ -386,16 +386,21 @@ module EnumStateMachine
|
|
386
386
|
end
|
387
387
|
end
|
388
388
|
|
389
|
-
#
|
389
|
+
# Describe the current validation errors on the given object. If none
|
390
390
|
# are specific, then the default error is interpeted as a "halt".
|
391
391
|
def errors_for(object)
|
392
392
|
object.errors.empty? ? 'Transition halted' : object.errors.full_messages * ', '
|
393
393
|
end
|
394
394
|
|
395
|
-
#
|
395
|
+
# Reset any errors previously added when invalidating the given object.
|
396
396
|
def reset(object)
|
397
397
|
object.errors.clear if supports_validations?
|
398
398
|
end
|
399
|
+
|
400
|
+
# Run state events around the object's validation process.
|
401
|
+
def around_validation(object)
|
402
|
+
object.class.state_machines.transitions(object, action, :after => false).perform { yield }
|
403
|
+
end
|
399
404
|
|
400
405
|
protected
|
401
406
|
# Whether observers are supported in the integration. Only true if
|
@@ -417,23 +422,22 @@ module EnumStateMachine
|
|
417
422
|
false
|
418
423
|
end
|
419
424
|
|
420
|
-
#
|
425
|
+
# Get the terminator to use for callbacks.
|
421
426
|
def callback_terminator
|
422
427
|
@terminator ||= lambda {|result| result == false}
|
423
428
|
end
|
424
429
|
|
425
|
-
#
|
430
|
+
# Determine the base scope to use when looking up translations.
|
426
431
|
def i18n_scope(klass)
|
427
432
|
klass.i18n_scope
|
428
433
|
end
|
429
434
|
|
430
|
-
# The default options to use when generating messages for validation
|
431
|
-
# errors
|
435
|
+
# The default options to use when generating messages for validation errors.
|
432
436
|
def default_error_message_options(object, attribute, message)
|
433
437
|
{:message => @messages[message]}
|
434
438
|
end
|
435
439
|
|
436
|
-
#
|
440
|
+
# Translate the given key / value combo. Translation keys are looked
|
437
441
|
# up in the following order:
|
438
442
|
# * <tt>#{i18n_scope}.state_machines.#{model_name}.#{machine_name}.#{plural_key}.#{value}</tt>
|
439
443
|
# * <tt>#{i18n_scope}.state_machines.#{model_name}.#{plural_key}.#{value}</tt>
|
@@ -459,7 +463,7 @@ module EnumStateMachine
|
|
459
463
|
klass.lookup_ancestors
|
460
464
|
end
|
461
465
|
|
462
|
-
#
|
466
|
+
# Initialize class-level extensions and defaults for this machine.
|
463
467
|
def after_initialize
|
464
468
|
super
|
465
469
|
load_locale
|
@@ -467,18 +471,18 @@ module EnumStateMachine
|
|
467
471
|
add_default_callbacks
|
468
472
|
end
|
469
473
|
|
470
|
-
#
|
474
|
+
# Load any locale files needed for translating validation errors.
|
471
475
|
def load_locale
|
472
476
|
I18n.load_path.unshift(@integration.locale_path) unless I18n.load_path.include?(@integration.locale_path)
|
473
477
|
end
|
474
478
|
|
475
|
-
#
|
479
|
+
# Load extensions to ActiveModel's Observers.
|
476
480
|
def load_observer_extensions
|
477
481
|
require 'enum_state_machine/integrations/active_model/observer'
|
478
482
|
require 'enum_state_machine/integrations/active_model/observer_update'
|
479
483
|
end
|
480
484
|
|
481
|
-
#
|
485
|
+
# Add a set of default callbacks that utilize the Observer extensions.
|
482
486
|
def add_default_callbacks
|
483
487
|
if supports_observers?
|
484
488
|
callbacks[:before] << Callback.new(:before) {|object, transition| notify(:before, object, transition)}
|
@@ -487,7 +491,7 @@ module EnumStateMachine
|
|
487
491
|
end
|
488
492
|
end
|
489
493
|
|
490
|
-
#
|
494
|
+
# Skip defining reader/writer methods since this is done automatically.
|
491
495
|
def define_state_accessor
|
492
496
|
name = self.name
|
493
497
|
|
@@ -497,24 +501,19 @@ module EnumStateMachine
|
|
497
501
|
end if supports_validations?
|
498
502
|
end
|
499
503
|
|
500
|
-
#
|
504
|
+
# Add hooks into validation for automatically firing events.
|
501
505
|
def define_action_helpers
|
502
506
|
super
|
503
507
|
define_validation_hook if runs_validations_on_action?
|
504
508
|
end
|
505
509
|
|
506
|
-
#
|
507
|
-
# :validation event
|
510
|
+
# Hook into validations by defining around callbacks for the
|
511
|
+
# :validation event.
|
508
512
|
def define_validation_hook
|
509
513
|
owner_class.set_callback(:validation, :around, self, :prepend => true)
|
510
514
|
end
|
511
515
|
|
512
|
-
#
|
513
|
-
def around_validation(object)
|
514
|
-
object.class.state_machines.transitions(object, action, :after => false).perform { yield }
|
515
|
-
end
|
516
|
-
|
517
|
-
# Creates a new callback in the callback chain, always inserting it
|
516
|
+
# Create a new callback in the callback chain, always inserting it
|
518
517
|
# before the default Observer callbacks that were created after
|
519
518
|
# initialization.
|
520
519
|
def add_callback(type, options, &block)
|
@@ -529,21 +528,21 @@ module EnumStateMachine
|
|
529
528
|
end
|
530
529
|
end
|
531
530
|
|
532
|
-
#
|
531
|
+
# Configure new states with the built-in humanize scheme.
|
533
532
|
def add_states(new_states)
|
534
533
|
super.each do |new_state|
|
535
534
|
new_state.human_name = lambda {|state, klass| translate(klass, :state, state.name)}
|
536
535
|
end
|
537
536
|
end
|
538
537
|
|
539
|
-
#
|
538
|
+
# Configure new events with the built-in humanize scheme.
|
540
539
|
def add_events(new_events)
|
541
540
|
super.each do |new_event|
|
542
541
|
new_event.human_name = lambda {|event, klass| translate(klass, :event, event.name)}
|
543
542
|
end
|
544
543
|
end
|
545
544
|
|
546
|
-
#
|
545
|
+
# Notify observers on the given object that a callback occurred
|
547
546
|
# involving the given transition. This will attempt to call the
|
548
547
|
# following methods on observers:
|
549
548
|
# * <tt>#{type}_#{qualified_event}_from_#{from}_to_#{to}</tt>
|
@@ -241,7 +241,7 @@ class TrafficLight
|
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
-
class VehicleTest < Test
|
244
|
+
class VehicleTest < MiniTest::Test
|
245
245
|
def setup
|
246
246
|
@vehicle = Vehicle.new
|
247
247
|
end
|
@@ -259,7 +259,7 @@ class VehicleTest < Test::Unit::TestCase
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
-
class VehicleUnsavedTest < Test
|
262
|
+
class VehicleUnsavedTest < MiniTest::Test
|
263
263
|
def setup
|
264
264
|
@vehicle = Vehicle.new
|
265
265
|
end
|
@@ -269,12 +269,12 @@ class VehicleUnsavedTest < Test::Unit::TestCase
|
|
269
269
|
end
|
270
270
|
|
271
271
|
def test_should_raise_exception_if_checking_invalid_state
|
272
|
-
|
272
|
+
assert_raises(IndexError) { @vehicle.state?(:invalid) }
|
273
273
|
end
|
274
274
|
|
275
275
|
def test_should_raise_exception_if_getting_name_of_invalid_state
|
276
276
|
@vehicle.state = 'invalid'
|
277
|
-
|
277
|
+
assert_raises(ArgumentError) { @vehicle.state_name }
|
278
278
|
end
|
279
279
|
|
280
280
|
def test_should_be_parked
|
@@ -318,7 +318,7 @@ class VehicleUnsavedTest < Test::Unit::TestCase
|
|
318
318
|
|
319
319
|
def test_should_have_a_transition_for_ignite
|
320
320
|
transition = @vehicle.ignite_transition
|
321
|
-
|
321
|
+
refute_nil transition
|
322
322
|
assert_equal 'parked', transition.from
|
323
323
|
assert_equal 'idling', transition.to
|
324
324
|
assert_equal :ignite, transition.event
|
@@ -357,7 +357,7 @@ class VehicleUnsavedTest < Test::Unit::TestCase
|
|
357
357
|
end
|
358
358
|
|
359
359
|
def test_should_raise_error_with_invalid_event_through_generic_event_runer
|
360
|
-
|
360
|
+
assert_raises(IndexError) { @vehicle.fire_state_event(:invalid) }
|
361
361
|
end
|
362
362
|
|
363
363
|
def test_should_allow_ignite
|
@@ -438,7 +438,7 @@ class VehicleUnsavedTest < Test::Unit::TestCase
|
|
438
438
|
end
|
439
439
|
end
|
440
440
|
|
441
|
-
class VehicleParkedTest < Test
|
441
|
+
class VehicleParkedTest < MiniTest::Test
|
442
442
|
def setup
|
443
443
|
@vehicle = Vehicle.new
|
444
444
|
end
|
@@ -481,7 +481,7 @@ class VehicleParkedTest < Test::Unit::TestCase
|
|
481
481
|
end
|
482
482
|
|
483
483
|
def test_should_raise_exception_if_repair_not_allowed!
|
484
|
-
exception =
|
484
|
+
exception = assert_raises(EnumStateMachine::InvalidTransition) {@vehicle.repair!}
|
485
485
|
assert_equal @vehicle, exception.object
|
486
486
|
assert_equal Vehicle.state_machine(:state), exception.machine
|
487
487
|
assert_equal :repair, exception.event
|
@@ -489,7 +489,7 @@ class VehicleParkedTest < Test::Unit::TestCase
|
|
489
489
|
end
|
490
490
|
end
|
491
491
|
|
492
|
-
class VehicleIdlingTest < Test
|
492
|
+
class VehicleIdlingTest < MiniTest::Test
|
493
493
|
def setup
|
494
494
|
@vehicle = Vehicle.new
|
495
495
|
@vehicle.ignite
|
@@ -508,7 +508,7 @@ class VehicleIdlingTest < Test::Unit::TestCase
|
|
508
508
|
end
|
509
509
|
|
510
510
|
def test_should_track_time_elapsed
|
511
|
-
|
511
|
+
refute_nil @vehicle.time_elapsed
|
512
512
|
end
|
513
513
|
|
514
514
|
def test_should_allow_park
|
@@ -546,7 +546,7 @@ class VehicleIdlingTest < Test::Unit::TestCase
|
|
546
546
|
end
|
547
547
|
end
|
548
548
|
|
549
|
-
class VehicleFirstGearTest < Test
|
549
|
+
class VehicleFirstGearTest < MiniTest::Test
|
550
550
|
def setup
|
551
551
|
@vehicle = Vehicle.new
|
552
552
|
@vehicle.ignite
|
@@ -586,7 +586,7 @@ class VehicleFirstGearTest < Test::Unit::TestCase
|
|
586
586
|
end
|
587
587
|
end
|
588
588
|
|
589
|
-
class VehicleSecondGearTest < Test
|
589
|
+
class VehicleSecondGearTest < MiniTest::Test
|
590
590
|
def setup
|
591
591
|
@vehicle = Vehicle.new
|
592
592
|
@vehicle.ignite
|
@@ -626,7 +626,7 @@ class VehicleSecondGearTest < Test::Unit::TestCase
|
|
626
626
|
end
|
627
627
|
end
|
628
628
|
|
629
|
-
class VehicleThirdGearTest < Test
|
629
|
+
class VehicleThirdGearTest < MiniTest::Test
|
630
630
|
def setup
|
631
631
|
@vehicle = Vehicle.new
|
632
632
|
@vehicle.ignite
|
@@ -666,7 +666,7 @@ class VehicleThirdGearTest < Test::Unit::TestCase
|
|
666
666
|
end
|
667
667
|
end
|
668
668
|
|
669
|
-
class VehicleStalledTest < Test
|
669
|
+
class VehicleStalledTest < MiniTest::Test
|
670
670
|
def setup
|
671
671
|
@vehicle = Vehicle.new
|
672
672
|
@vehicle.ignite
|
@@ -729,7 +729,7 @@ class VehicleStalledTest < Test::Unit::TestCase
|
|
729
729
|
end
|
730
730
|
end
|
731
731
|
|
732
|
-
class VehicleRepairedTest < Test
|
732
|
+
class VehicleRepairedTest < MiniTest::Test
|
733
733
|
def setup
|
734
734
|
@vehicle = Vehicle.new
|
735
735
|
@vehicle.ignite
|
@@ -747,7 +747,7 @@ class VehicleRepairedTest < Test::Unit::TestCase
|
|
747
747
|
end
|
748
748
|
end
|
749
749
|
|
750
|
-
class VehicleLockedTest < Test
|
750
|
+
class VehicleLockedTest < MiniTest::Test
|
751
751
|
def setup
|
752
752
|
@vehicle = Vehicle.new
|
753
753
|
@vehicle.state = 'locked'
|
@@ -774,7 +774,7 @@ class VehicleLockedTest < Test::Unit::TestCase
|
|
774
774
|
end
|
775
775
|
end
|
776
776
|
|
777
|
-
class VehicleWithParallelEventsTest < Test
|
777
|
+
class VehicleWithParallelEventsTest < MiniTest::Test
|
778
778
|
def setup
|
779
779
|
@vehicle = Vehicle.new
|
780
780
|
end
|
@@ -793,7 +793,9 @@ class VehicleWithParallelEventsTest < Test::Unit::TestCase
|
|
793
793
|
end
|
794
794
|
|
795
795
|
def test_should_raise_exception_if_any_event_cannot_transition_on_bang
|
796
|
-
exception =
|
796
|
+
exception = assert_raises(EnumStateMachine::InvalidParallelTransition) {
|
797
|
+
@vehicle.fire_events!(:ignite, :cancel_insurance)
|
798
|
+
}
|
797
799
|
assert_equal @vehicle, exception.object
|
798
800
|
assert_equal [:ignite, :cancel_insurance], exception.events
|
799
801
|
end
|
@@ -808,7 +810,7 @@ class VehicleWithParallelEventsTest < Test::Unit::TestCase
|
|
808
810
|
end
|
809
811
|
end
|
810
812
|
|
811
|
-
class VehicleWithEventAttributesTest < Test
|
813
|
+
class VehicleWithEventAttributesTest < MiniTest::Test
|
812
814
|
def setup
|
813
815
|
@vehicle = Vehicle.new
|
814
816
|
@vehicle.state_event = 'ignite'
|
@@ -836,7 +838,7 @@ class VehicleWithEventAttributesTest < Test::Unit::TestCase
|
|
836
838
|
end
|
837
839
|
end
|
838
840
|
|
839
|
-
class MotorcycleTest < Test
|
841
|
+
class MotorcycleTest < MiniTest::Test
|
840
842
|
def setup
|
841
843
|
@motorcycle = Motorcycle.new
|
842
844
|
end
|
@@ -880,7 +882,7 @@ class MotorcycleTest < Test::Unit::TestCase
|
|
880
882
|
end
|
881
883
|
end
|
882
884
|
|
883
|
-
class CarTest < Test
|
885
|
+
class CarTest < MiniTest::Test
|
884
886
|
def setup
|
885
887
|
@car = Car.new
|
886
888
|
end
|
@@ -927,7 +929,7 @@ class CarTest < Test::Unit::TestCase
|
|
927
929
|
end
|
928
930
|
end
|
929
931
|
|
930
|
-
class CarBackingUpTest < Test
|
932
|
+
class CarBackingUpTest < MiniTest::Test
|
931
933
|
def setup
|
932
934
|
@car = Car.new
|
933
935
|
@car.reverse
|
@@ -970,7 +972,7 @@ class CarBackingUpTest < Test::Unit::TestCase
|
|
970
972
|
end
|
971
973
|
end
|
972
974
|
|
973
|
-
class AutoShopAvailableTest < Test
|
975
|
+
class AutoShopAvailableTest < MiniTest::Test
|
974
976
|
def setup
|
975
977
|
@auto_shop = AutoShop.new
|
976
978
|
end
|
@@ -988,7 +990,7 @@ class AutoShopAvailableTest < Test::Unit::TestCase
|
|
988
990
|
end
|
989
991
|
end
|
990
992
|
|
991
|
-
class AutoShopBusyTest < Test
|
993
|
+
class AutoShopBusyTest < MiniTest::Test
|
992
994
|
def setup
|
993
995
|
@auto_shop = AutoShop.new
|
994
996
|
@auto_shop.tow_vehicle
|
@@ -1011,7 +1013,7 @@ class AutoShopBusyTest < Test::Unit::TestCase
|
|
1011
1013
|
end
|
1012
1014
|
end
|
1013
1015
|
|
1014
|
-
class TrafficLightStopTest < Test
|
1016
|
+
class TrafficLightStopTest < MiniTest::Test
|
1015
1017
|
def setup
|
1016
1018
|
@light = TrafficLight.new
|
1017
1019
|
@light.state = 'stop'
|
@@ -1035,7 +1037,7 @@ class TrafficLightStopTest < Test::Unit::TestCase
|
|
1035
1037
|
end
|
1036
1038
|
end
|
1037
1039
|
|
1038
|
-
class TrafficLightProceedTest < Test
|
1040
|
+
class TrafficLightProceedTest < MiniTest::Test
|
1039
1041
|
def setup
|
1040
1042
|
@light = TrafficLight.new
|
1041
1043
|
@light.state = 'proceed'
|
@@ -1050,7 +1052,7 @@ class TrafficLightProceedTest < Test::Unit::TestCase
|
|
1050
1052
|
end
|
1051
1053
|
end
|
1052
1054
|
|
1053
|
-
class TrafficLightCautionTest < Test
|
1055
|
+
class TrafficLightCautionTest < MiniTest::Test
|
1054
1056
|
def setup
|
1055
1057
|
@light = TrafficLight.new
|
1056
1058
|
@light.state = 'caution'
|
data/test/test_helper.rb
CHANGED
@@ -3,5 +3,17 @@ if ENV['COVERAGE']
|
|
3
3
|
SimpleCov.start { add_filter '/test/' }
|
4
4
|
end
|
5
5
|
|
6
|
-
require 'test/unit'
|
6
|
+
#require 'test/unit'
|
7
|
+
require 'minitest'
|
8
|
+
require "minitest/autorun"
|
7
9
|
require 'enum_state_machine'
|
10
|
+
|
11
|
+
class MiniTest::Test
|
12
|
+
def assert_nothing_raised
|
13
|
+
yield
|
14
|
+
rescue => ex
|
15
|
+
assert_nil ex
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :assert_nothing_thrown, :assert_nothing_raised
|
19
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class AssertionsBaseTest < Test
|
3
|
+
class AssertionsBaseTest < MiniTest::Test
|
4
4
|
include EnumStateMachine::Assertions
|
5
5
|
|
6
6
|
def default_test
|
@@ -13,7 +13,9 @@ class AssertValidKeysTest < AssertionsBaseTest
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_should_raise_exception_if_key_is_invalid
|
16
|
-
exception =
|
16
|
+
exception = assert_raises(ArgumentError) {
|
17
|
+
assert_valid_keys({:name => 'foo', :value => 'bar', :invalid => true}, :name, :value, :force)
|
18
|
+
}
|
17
19
|
assert_equal 'Invalid key(s): invalid', exception.message
|
18
20
|
end
|
19
21
|
end
|
@@ -29,12 +31,16 @@ class AssertExclusiveKeysTest < AssertionsBaseTest
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def test_should_raise_exception_if_two_keys_found
|
32
|
-
exception =
|
34
|
+
exception = assert_raises(ArgumentError) {
|
35
|
+
assert_exclusive_keys({:only => :parked, :except => :parked}, :only, :except)
|
36
|
+
}
|
33
37
|
assert_equal 'Conflicting keys: only, except', exception.message
|
34
38
|
end
|
35
39
|
|
36
40
|
def test_should_raise_exception_if_multiple_keys_found
|
37
|
-
exception =
|
41
|
+
exception = assert_raises(ArgumentError) {
|
42
|
+
assert_exclusive_keys({:only => :parked, :except => :parked, :on => :park}, :only, :except, :with)
|
43
|
+
}
|
38
44
|
assert_equal 'Conflicting keys: only, except', exception.message
|
39
45
|
end
|
40
46
|
end
|