Sha256: 10a9af575929b0e2b13387c0f04802c6850db9d56969e9afb5a1313ea6ef3fb9

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

require_relative '../../test_helper'

class TransitionCollectionWithMixedActionsTest < StateMachinesTest
  def setup
    @klass = Class.new do
      def save
        true
      end
    end

    @state = StateMachines::Machine.new(@klass, initial: :parked, action: :save)
    @state.state :idling
    @state.event :ignite

    @status = StateMachines::Machine.new(@klass, :status, initial: :first_gear)
    @status.state :second_gear
    @status.event :shift_up

    @object = @klass.new

    @transitions = StateMachines::TransitionCollection.new([
      @state_transition = StateMachines::Transition.new(@object, @state, :ignite, :parked, :idling),
      @status_transition = StateMachines::Transition.new(@object, @status, :shift_up, :first_gear, :second_gear)
    ])
    @result = @transitions.perform
  end

  def test_should_succeed
    assert_equal true, @result
  end

  def test_should_persist_states
    assert_equal 'idling', @object.state
    assert_equal 'second_gear', @object.status
  end

  def test_should_store_results_in_transitions
    assert_equal true, @state_transition.result
    assert_nil @status_transition.result
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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