class AttributeTransitionCollectionMarshallingTest

Public Instance Methods

setup() click to toggle source
# File test/unit/transition_collection_test.rb, line 2034
def setup
  @klass = Class.new
  self.class.const_set('Example', @klass)
  
  @machine = StateMachine::Machine.new(@klass, :initial => :parked, :action => :save)
  @machine.state :idling
  @machine.event :ignite
  
  @object = @klass.new
  @object.state_event = 'ignite'
end
teardown() click to toggle source
# File test/unit/transition_collection_test.rb, line 2092
def teardown
  self.class.send(:remove_const, 'Example')
end
test_should_marshal_during_action() click to toggle source
# File test/unit/transition_collection_test.rb, line 2054
def test_should_marshal_during_action
  assert_nothing_raised do
    transitions(:after => false).perform do
       Marshal.dump(@object)
       true
    end
    
    transitions.perform do
       Marshal.dump(@object)
       true
    end
  end
end
test_should_marshal_during_after_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 2068
def test_should_marshal_during_after_callbacks
  @machine.after_transition {|object, transition| Marshal.dump(object)}
  assert_nothing_raised do
    transitions(:after => false).perform { true }
    transitions.perform { true }
  end
end
test_should_marshal_during_around_callbacks_after_yield() click to toggle source
# File test/unit/transition_collection_test.rb, line 2084
def test_should_marshal_during_around_callbacks_after_yield
  @machine.around_transition {|object, transition, block| block.call; Marshal.dump(object)}
  assert_nothing_raised do
    transitions(:after => false).perform { true }
    transitions.perform { true }
  end
end
test_should_marshal_during_around_callbacks_before_yield() click to toggle source
# File test/unit/transition_collection_test.rb, line 2076
def test_should_marshal_during_around_callbacks_before_yield
  @machine.around_transition {|object, transition, block| Marshal.dump(object); block.call}
  assert_nothing_raised do
    transitions(:after => false).perform { true }
    transitions.perform { true }
  end
end
test_should_marshal_during_before_callbacks() click to toggle source
# File test/unit/transition_collection_test.rb, line 2046
def test_should_marshal_during_before_callbacks
  @machine.before_transition {|object, transition| Marshal.dump(object)}
  assert_nothing_raised do
    transitions(:after => false).perform { true }
    transitions.perform { true }
  end
end