class StateCollectionWithStateMatchersTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/state_collection_test.rb, line 138 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @states = StateMachine::StateCollection.new(@machine) @states << @state = StateMachine::State.new(@machine, :parked, :if => lambda {|value| !value.nil?}) @machine.states.concat(@states) @object = @klass.new @object.state = 1 end
test_should_find_state_for_object_if_value_is_known()
click to toggle source
# File test/unit/state_collection_test.rb, line 159 def test_should_find_state_for_object_if_value_is_known assert_equal @state, @states.match(@object) end
test_should_match_if_value_matches()
click to toggle source
# File test/unit/state_collection_test.rb, line 150 def test_should_match_if_value_matches assert @states.matches?(@object, :parked) end
test_should_not_match_if_value_does_not_match()
click to toggle source
# File test/unit/state_collection_test.rb, line 154 def test_should_not_match_if_value_does_not_match @object.state = nil assert !@states.matches?(@object, :parked) end