class TransitionCollectionPartialInvalidTest

Public Instance Methods

setup() click to toggle source
# File test/unit/transition_collection_test.rb, line 105
def setup
  @klass = Class.new do
    attr_accessor :ran_transaction
  end
  
  @machine = StateMachine::Machine.new(@klass, :initial => :parked)
  @machine.state :idling
  @machine.event :ignite
  @machine.before_transition {@ran_before = true}
  @machine.after_transition {@ran_after = true}
  @machine.around_transition {|block| @ran_around_before = true; block.call; @ran_around_after = true}
  
  class << @machine
    def within_transaction(object)
      object.ran_transaction = true
    end
  end
  
  @object = @klass.new
  
  @transitions = StateMachine::TransitionCollection.new([
    StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling),
    false
  ])
end
test_should_not_persist_states() click to toggle source
# File test/unit/transition_collection_test.rb, line 153
def test_should_not_persist_states
  assert_equal 'parked', @object.state
end
test_should_not_run_after_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 157
def test_should_not_run_after_callbacks
  assert !@ran_after
end
test_should_not_run_around_callbacks_after_yield() click to toggle source
# File test/unit/transition_collection_test.rb, line 165
def test_should_not_run_around_callbacks_after_yield
  assert !@ran_around_after
end
test_should_not_run_around_callbacks_before_yield() click to toggle source
# File test/unit/transition_collection_test.rb, line 161
def test_should_not_run_around_callbacks_before_yield
  assert !@ran_around_before
end
test_should_not_run_before_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 149
def test_should_not_run_before_callbacks
  assert !@ran_before
end
test_should_not_run_perform_block() click to toggle source
# File test/unit/transition_collection_test.rb, line 143
def test_should_not_run_perform_block
  ran_block = false
  @transitions.perform { ran_block = true }
  assert !ran_block
end
test_should_not_start_transaction() click to toggle source
# File test/unit/transition_collection_test.rb, line 139
def test_should_not_start_transaction
  assert !@object.ran_transaction
end
test_should_not_store_invalid_values() click to toggle source
# File test/unit/transition_collection_test.rb, line 131
def test_should_not_store_invalid_values
  assert_equal 1, @transitions.length
end
test_should_not_succeed() click to toggle source
# File test/unit/transition_collection_test.rb, line 135
def test_should_not_succeed
  assert_equal false, @transitions.perform
end