Sha256: 7bd655435e50e2fa0f5aba8a480b55f881cf8655c810d6b56d9d0ba4ad48ace0

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 KB

Contents

require_relative '../../test_helper'

class PathCollectionWithPathsTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass)
    @machine.state :parked, :idling, :first_gear
    @machine.event :ignite do
      transition parked: :idling
    end
    @machine.event :shift_up do
      transition idling: :first_gear
    end

    @object = @klass.new
    @object.state = 'parked'

    @paths = StateMachines::PathCollection.new(@object, @machine)
  end

  def test_should_enumerate_paths
    assert_equal [[
      StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling),
      StateMachines::Transition.new(@object, @machine, :shift_up, :idling, :first_gear)
    ]], @paths
  end

  def test_should_have_a_from_name
    assert_equal :parked, @paths.from_name
  end

  def test_should_not_have_a_to_name
    assert_nil @paths.to_name
  end

  def test_should_have_from_states
    assert_equal [:parked, :idling], @paths.from_states
  end

  def test_should_have_to_states
    assert_equal [:idling, :first_gear], @paths.to_states
  end

  def test_should_have_no_events
    assert_equal [:ignite, :shift_up], @paths.events
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/path_collection/path_collection_with_paths_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/path_collection/path_collection_with_paths_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/path_collection/path_collection_with_paths_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.4.0 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.3.0 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.2.2 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.2.1 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.2.0 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.1.4 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.1.3 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.1.2 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.1.1 test/unit/path_collection/path_collection_with_paths_test.rb
state_machines-0.1.0 test/unit/path_collection/path_collection_with_paths_test.rb