Sha256: a861e1e16b864bb22dec71f2cbef41d64975d028a598262b98cb72af83df8adc

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

require_relative '../../test_helper'

class TransitionCollectionTest < StateMachinesTest
  def test_should_raise_exception_if_invalid_option_specified
    exception = assert_raises(ArgumentError) { StateMachines::TransitionCollection.new([], invalid: true) }
    assert_equal 'Unknown key: :invalid. Valid keys are: :actions, :after, :transaction', exception.message
  end

  def test_should_raise_exception_if_multiple_transitions_for_same_attribute_specified
    @klass = Class.new

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

    @object = @klass.new

    exception = assert_raises(ArgumentError) do
      StateMachines::TransitionCollection.new([
        StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling),
        StateMachines::Transition.new(@object, @machine, :ignite, :parked, :idling)
      ])
    end
    assert_equal 'Cannot perform multiple transitions in parallel for the same state machine attribute', exception.message
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

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