class TransitionTest

Public Instance Methods

setup() click to toggle source
# File test/unit/transition_test.rb, line 4
def setup
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass)
  @machine.state :parked, :idling
  @machine.event :ignite
  
  @object = @klass.new
  @object.state = 'parked'
  
  @transition = StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
end
test_should_generate_attributes() click to toggle source
# File test/unit/transition_test.rb, line 80
def test_should_generate_attributes
  expected = {:object => @object, :attribute => :state, :event => :ignite, :from => 'parked', :to => 'idling'}
  assert_equal expected, @transition.attributes
end
test_should_have_a_from_name() click to toggle source
# File test/unit/transition_test.rb, line 40
def test_should_have_a_from_name
  assert_equal :parked, @transition.from_name
end
test_should_have_a_from_value() click to toggle source
# File test/unit/transition_test.rb, line 36
def test_should_have_a_from_value
  assert_equal 'parked', @transition.from
end
test_should_have_a_human_event() click to toggle source
# File test/unit/transition_test.rb, line 32
def test_should_have_a_human_event
  assert_equal 'ignite', @transition.human_event
end
test_should_have_a_human_from_name() click to toggle source
# File test/unit/transition_test.rb, line 48
def test_should_have_a_human_from_name
  assert_equal 'parked', @transition.human_from_name
end
test_should_have_a_human_to_name() click to toggle source
# File test/unit/transition_test.rb, line 64
def test_should_have_a_human_to_name
  assert_equal 'idling', @transition.human_to_name
end
test_should_have_a_machine() click to toggle source
# File test/unit/transition_test.rb, line 20
def test_should_have_a_machine
  assert_equal @machine, @transition.machine
end
test_should_have_a_qualified_event() click to toggle source
# File test/unit/transition_test.rb, line 28
def test_should_have_a_qualified_event
  assert_equal :ignite, @transition.qualified_event
end
test_should_have_a_qualified_from_name() click to toggle source
# File test/unit/transition_test.rb, line 44
def test_should_have_a_qualified_from_name
  assert_equal :parked, @transition.qualified_from_name
end
test_should_have_a_qualified_to_name() click to toggle source
# File test/unit/transition_test.rb, line 60
def test_should_have_a_qualified_to_name
  assert_equal :idling, @transition.qualified_to_name
end
test_should_have_a_to_name() click to toggle source
# File test/unit/transition_test.rb, line 56
def test_should_have_a_to_name
  assert_equal :idling, @transition.to_name
end
test_should_have_a_to_value() click to toggle source
# File test/unit/transition_test.rb, line 52
def test_should_have_a_to_value
  assert_equal 'idling', @transition.to
end
test_should_have_an_attribute() click to toggle source
# File test/unit/transition_test.rb, line 68
def test_should_have_an_attribute
  assert_equal :state, @transition.attribute
end
test_should_have_an_event() click to toggle source
# File test/unit/transition_test.rb, line 24
def test_should_have_an_event
  assert_equal :ignite, @transition.event
end
test_should_have_an_object() click to toggle source
# File test/unit/transition_test.rb, line 16
def test_should_have_an_object
  assert_equal @object, @transition.object
end
test_should_have_empty_args() click to toggle source
# File test/unit/transition_test.rb, line 85
def test_should_have_empty_args
  assert_equal [], @transition.args
end
test_should_not_be_transient() click to toggle source
# File test/unit/transition_test.rb, line 76
def test_should_not_be_transient
  assert_equal false, @transition.transient?
end
test_should_not_have_a_result() click to toggle source
# File test/unit/transition_test.rb, line 89
def test_should_not_have_a_result
  assert_nil @transition.result
end
test_should_not_have_an_action() click to toggle source
# File test/unit/transition_test.rb, line 72
def test_should_not_have_an_action
  assert_nil @transition.action
end
test_should_use_pretty_inspect() click to toggle source
# File test/unit/transition_test.rb, line 93
def test_should_use_pretty_inspect
  assert_equal '#<StateMachine::Transition attribute=:state event=:ignite from="parked" from_name=:parked to="idling" to_name=:idling>', @transition.inspect
end