class MachineWithStateMatchersTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/machine_test.rb, line 2188 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) end
test_should_empty_array_for_all_matcher()
click to toggle source
# File test/unit/machine_test.rb, line 2193 def test_should_empty_array_for_all_matcher assert_equal [], @machine.state(StateMachine::AllMatcher.instance) end
test_should_eval_context_for_matching_states()
click to toggle source
# File test/unit/machine_test.rb, line 2211 def test_should_eval_context_for_matching_states contexts_run = [] @machine.event(StateMachine::BlacklistMatcher.new([:parked])) { contexts_run << self.name } @machine.event :parked assert_equal [], contexts_run @machine.event :idling assert_equal [:idling], contexts_run @machine.event :first_gear, :second_gear assert_equal [:idling, :first_gear, :second_gear], contexts_run end
test_should_not_allow_configurations()
click to toggle source
# File test/unit/machine_test.rb, line 2201 def test_should_not_allow_configurations exception = assert_raise(ArgumentError) { @machine.state(StateMachine::BlacklistMatcher.new([:parked]), :human_name => 'Parked') } assert_equal 'Cannot configure states when using matchers (using {:human_name=>"Parked"})', exception.message end
test_should_return_referenced_states_for_blacklist_matcher()
click to toggle source
# File test/unit/machine_test.rb, line 2197 def test_should_return_referenced_states_for_blacklist_matcher assert_instance_of StateMachine::State, @machine.state(StateMachine::BlacklistMatcher.new([:parked])) end
test_should_track_referenced_states()
click to toggle source
# File test/unit/machine_test.rb, line 2206 def test_should_track_referenced_states @machine.state(StateMachine::BlacklistMatcher.new([:parked])) assert_equal [nil, :parked], @machine.states.map {|state| state.name} end