Sha256: 532644d7f87b62ff2c6fe90d4c07814a190169ba4e8c002e29536c4e9b63a963

Contents?: true

Size: 1.35 KB

Versions: 14

Compression:

Stored size: 1.35 KB

Contents

require_relative '../../test_helper'

class AttributeTransitionCollectionWithActionFailedTest < StateMachinesTest
  def setup
    @klass = Class.new

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

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

    @object = @klass.new
    @object.state_event = 'ignite'
    @object.status_event = 'shift_up'

    @transitions = StateMachines::AttributeTransitionCollection.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 { false }
  end

  def test_should_not_succeed
    assert_equal false, @result
  end

  def test_should_not_persist_states
    assert_equal 'parked', @object.state
    assert_equal 'first_gear', @object.status
  end

  def test_should_not_clear_events
    assert_equal :ignite, @object.state_event
    assert_equal :shift_up, @object.status_event
  end

  def test_should_not_write_event_transitions
    assert_nil @object.send(:state_event_transition)
    assert_nil @object.send(:status_event_transition)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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