class TransitionCollectionWithActionFailedTest

Public Instance Methods

save() click to toggle source
# File test/unit/transition_collection_test.rb, line 760
def save
  false
end
setup() click to toggle source
# File test/unit/transition_collection_test.rb, line 758
def setup
  @klass = Class.new do
    def save
      false
    end
  end
  @before_count = 0
  @around_before_count = 0
  @after_count = 0
  @around_after_count = 0
  @failure_count = 0
  
  @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save)
  @machine.state :idling
  @machine.event :ignite
  
  @machine.before_transition {@before_count += 1}
  @machine.after_transition {@after_count += 1}
  @machine.around_transition {|block| @around_before_count += 1; block.call; @around_after_count += 1}
  @machine.after_failure {@failure_count += 1}
  
  @object = @klass.new
  
  @transitions = StateMachine::TransitionCollection.new([
    StateMachine::Transition.new(@object, @machine, :ignite, :parked, :idling)
  ])
  @result = @transitions.perform
end
test_should_not_persist_state() click to toggle source
# File test/unit/transition_collection_test.rb, line 791
def test_should_not_persist_state
  assert_equal 'parked', @object.state
end
test_should_not_run_after_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 803
def test_should_not_run_after_callbacks
  assert_equal 0, @after_count
end
test_should_not_run_around_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 807
def test_should_not_run_around_callbacks
  assert_equal 0, @around_after_count
end
test_should_not_succeed() click to toggle source
# File test/unit/transition_collection_test.rb, line 787
def test_should_not_succeed
  assert_equal false, @result
end
test_should_run_around_callbacks_before_yield() click to toggle source
# File test/unit/transition_collection_test.rb, line 799
def test_should_run_around_callbacks_before_yield
  assert_equal 1, @around_before_count
end
test_should_run_before_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 795
def test_should_run_before_callbacks
  assert_equal 1, @before_count
end
test_should_run_failure_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 811
def test_should_run_failure_callbacks
  assert_equal 1, @failure_count
end