class DataMapperTest::MachineWithFailedAfterCallbacksTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 974
 def setup
  callbacks = []
  
  @resource = new_resource
  @machine = StateMachine::Machine.new(@resource)
  @machine.state :parked, :idling
  @machine.event :ignite
  @machine.after_transition {callbacks << :after_1; throw :halt}
  @machine.after_transition {callbacks << :after_2}
  @machine.around_transition {|block| callbacks << :around_before; block.call; callbacks << :around_after}
  
  @record = @resource.new(:state => 'parked')
  @transition = StateMachine::Transition.new(@record, @machine, :ignite, :parked, :idling)
  @result = @transition.perform
  
  @callbacks = callbacks
end
test_should_be_successful() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 992
def test_should_be_successful
  assert @result
end
test_should_change_current_state() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 996
def test_should_change_current_state
  assert_equal 'idling', @record.state
end
test_should_not_run_further_after_callbacks() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1004
def test_should_not_run_further_after_callbacks
  assert_equal [:around_before, :around_after, :after_1], @callbacks
end
test_should_save_record() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1000
def test_should_save_record
  assert !(@record.respond_to?(:new?) ? @record.new? : @record.new_record?)
end