class StateCollectionWithCustomStateValuesTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_collection_test.rb, line 111
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass)
  @states = StateMachine::StateCollection.new(@machine)
  
  @states << @state = StateMachine::State.new(@machine, :parked, :value => 1)
  @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 132
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 123
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 127
def test_should_not_match_if_value_does_not_match
  @object.state = 2
  assert !@states.matches?(@object, :parked)
end