class StateWithConflictingMachineTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_test.rb, line 529
def setup
  require 'stringio'
  @original_stderr, $stderr = $stderr, StringIO.new
  
  @klass = Class.new
  @state_machine = StateMachine::Machine.new(@klass, :state)
  @state_machine.states << @state = StateMachine::State.new(@state_machine, :parked)
end
teardown() click to toggle source
# File test/unit/state_test.rb, line 559
def teardown
  $stderr = @original_stderr
end
test_should_not_output_warning_if_using_different_namespace() click to toggle source
# File test/unit/state_test.rb, line 552
def test_should_not_output_warning_if_using_different_namespace
  @status_machine = StateMachine::Machine.new(@klass, :status, :namespace => 'alarm')
  @status_machine.states << @state = StateMachine::State.new(@status_machine, :parked)
  
  assert_equal '', $stderr.string
end
test_should_not_output_warning_if_using_same_attribute() click to toggle source
# File test/unit/state_test.rb, line 545
def test_should_not_output_warning_if_using_same_attribute
  @status_machine = StateMachine::Machine.new(@klass, :status, :attribute => :state)
  @status_machine.states << @state = StateMachine::State.new(@status_machine, :parked)
  
  assert_equal '', $stderr.string
end
test_should_output_warning_if_using_different_attribute() click to toggle source
# File test/unit/state_test.rb, line 538
def test_should_output_warning_if_using_different_attribute
  @status_machine = StateMachine::Machine.new(@klass, :status)
  @status_machine.states << @state = StateMachine::State.new(@status_machine, :parked)
  
  assert_equal "State :parked for :status is already defined in :state\n", $stderr.string
end