class EventWithInvalidCurrentStateTest

Public Instance Methods

setup() click to toggle source
# File test/unit/event_test.rb, line 860
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass)
  @machine.state :parked, :idling
  
  @machine.events << @event = StateMachine::Event.new(@machine, :ignite)
  @event.transition(:parked => :idling)
  
  @object = @klass.new
  @object.state = 'invalid'
end
test_should_raise_exception_when_checking_availability() click to toggle source
# File test/unit/event_test.rb, line 872
def test_should_raise_exception_when_checking_availability
  exception = assert_raise(ArgumentError) { @event.can_fire?(@object) }
  assert_equal '"invalid" is not a known state value', exception.message
end
test_should_raise_exception_when_finding_transition() click to toggle source
# File test/unit/event_test.rb, line 877
def test_should_raise_exception_when_finding_transition
  exception = assert_raise(ArgumentError) { @event.transition_for(@object) }
  assert_equal '"invalid" is not a known state value', exception.message
end
test_should_raise_exception_when_firing() click to toggle source
# File test/unit/event_test.rb, line 882
def test_should_raise_exception_when_firing
  exception = assert_raise(ArgumentError) { @event.fire(@object) }
  assert_equal '"invalid" is not a known state value', exception.message
end