class StateContextWithMatchingTransitionTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_context_test.rb, line 114
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass, :initial => :parked)
  @state = @machine.state :parked
  
  @state_context = StateMachine::StateContext.new(@state)
  @state_context.transition(:to => :idling, :on => :ignite)
  
  @event = @machine.event(:ignite)
  @object = @klass.new
end
test_should_be_able_to_fire() click to toggle source
# File test/unit/state_context_test.rb, line 126
def test_should_be_able_to_fire
  assert @event.can_fire?(@object)
end
test_should_have_a_transition() click to toggle source
# File test/unit/state_context_test.rb, line 130
def test_should_have_a_transition
  transition = @event.transition_for(@object)
  assert_not_nil transition
  assert_equal 'parked', transition.from
  assert_equal 'idling', transition.to
  assert_equal :ignite, transition.event
end