class EventWithTransitionWithNilToStateTest

Public Instance Methods

setup() click to toggle source
# File test/unit/event_test.rb, line 734
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass)
  @machine.state nil, :idling
  
  @machine.events << @event = StateMachine::Event.new(@machine, :park)
  @event.transition(:idling => nil)
  
  @object = @klass.new
  @object.state = 'idling'
end
test_should_be_able_to_fire() click to toggle source
# File test/unit/event_test.rb, line 746
def test_should_be_able_to_fire
  assert @event.can_fire?(@object)
end
test_should_fire() click to toggle source
# File test/unit/event_test.rb, line 758
def test_should_fire
  assert @event.fire(@object)
end
test_should_have_a_transition() click to toggle source
# File test/unit/event_test.rb, line 750
def test_should_have_a_transition
  transition = @event.transition_for(@object)
  assert_not_nil transition
  assert_equal 'idling', transition.from
  assert_equal nil, transition.to
  assert_equal :park, transition.event
end
test_should_not_change_the_current_state() click to toggle source
# File test/unit/event_test.rb, line 762
def test_should_not_change_the_current_state
  @event.fire(@object)
  assert_equal nil, @object.state
end