Sha256: 65924d9be4814d7c94506524d9bb6807127fc170176b62cded9d0fe2bb9d3aa4

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

require_relative '../../test_helper'
require 'stringio'

class StateWithConflictingMachineTest < StateMachinesTest
  def setup
    @original_stderr, $stderr = $stderr, StringIO.new

    @klass = Class.new
    @state_machine = StateMachines::Machine.new(@klass, :state)
    @state_machine.states << @state = StateMachines::State.new(@state_machine, :parked)
  end

  def test_should_output_warning_if_using_different_attribute
    @status_machine = StateMachines::Machine.new(@klass, :status)
    @status_machine.states << @state = StateMachines::State.new(@status_machine, :parked)

    assert_equal "State :parked for :status is already defined in :state\n", $stderr.string
  end

  def test_should_not_output_warning_if_using_same_attribute
    @status_machine = StateMachines::Machine.new(@klass, :status, attribute: :state)
    @status_machine.states << @state = StateMachines::State.new(@status_machine, :parked)

    assert_equal '', $stderr.string
  end

  def test_should_not_output_warning_if_using_different_namespace
    @status_machine = StateMachines::Machine.new(@klass, :status, namespace: 'alarm')
    @status_machine.states << @state = StateMachines::State.new(@status_machine, :parked)

    assert_equal '', $stderr.string
  end

  def teardown
    $stderr = @original_stderr
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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