class EventTransitionsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/event_test.rb, line 359
def setup
  @machine = StateMachine::Machine.new(Class.new)
  @machine.events << @event = StateMachine::Event.new(@machine, :ignite)
end
test_should_allow_except_from_option() click to toggle source
# File test/unit/event_test.rb, line 397
def test_should_allow_except_from_option
  assert_nothing_raised {@event.transition(:except_from => :idling)}
end
test_should_allow_transitioning_from_a_single_state() click to toggle source
# File test/unit/event_test.rb, line 401
def test_should_allow_transitioning_from_a_single_state
  assert @event.transition(:parked => :idling)
end
test_should_allow_transitioning_from_multiple_states() click to toggle source
# File test/unit/event_test.rb, line 405
def test_should_allow_transitioning_from_multiple_states
  assert @event.transition([:parked, :idling] => :idling)
end
test_should_allow_transitioning_without_a_from_state() click to toggle source
# File test/unit/event_test.rb, line 393
def test_should_allow_transitioning_without_a_from_state
  assert_nothing_raised {@event.transition(:to => :idling)}
end
test_should_allow_transitioning_without_a_to_state() click to toggle source
# File test/unit/event_test.rb, line 389
def test_should_allow_transitioning_without_a_to_state
  assert_nothing_raised {@event.transition(:from => :parked)}
end
test_should_automatically_set_on_option() click to toggle source
# File test/unit/event_test.rb, line 373
def test_should_automatically_set_on_option
  branch = @event.transition(:to => :idling)
  assert_instance_of StateMachine::WhitelistMatcher, branch.event_requirement
  assert_equal [:ignite], branch.event_requirement.values
end
test_should_have_transitions() click to toggle source
# File test/unit/event_test.rb, line 409
def test_should_have_transitions
  branch = @event.transition(:to => :idling)
  assert_equal [branch], @event.branches
end
test_should_not_allow_except_on_option() click to toggle source
# File test/unit/event_test.rb, line 384
def test_should_not_allow_except_on_option
  exception = assert_raise(ArgumentError) {@event.transition(:except_on => :ignite)}
  assert_equal 'Invalid key(s): except_on', exception.message
end
test_should_not_allow_except_to_option() click to toggle source
# File test/unit/event_test.rb, line 379
def test_should_not_allow_except_to_option
  exception = assert_raise(ArgumentError) {@event.transition(:except_to => :parked)}
  assert_equal 'Invalid key(s): except_to', exception.message
end
test_should_not_allow_on_option() click to toggle source
# File test/unit/event_test.rb, line 368
def test_should_not_allow_on_option
  exception = assert_raise(ArgumentError) {@event.transition(:on => :ignite)}
  assert_equal 'Invalid key(s): on', exception.message
end
test_should_not_raise_exception_if_implicit_option_specified() click to toggle source
# File test/unit/event_test.rb, line 364
def test_should_not_raise_exception_if_implicit_option_specified
  assert_nothing_raised {@event.transition(:invalid => :valid)}
end