class CallbackWithAroundTypeAndBoundMethodTest

Public Instance Methods

setup() click to toggle source
# File test/unit/callback_test.rb, line 682
def setup
  @object = Object.new
end
test_should_call_method_within_the_context_of_the_object() click to toggle source
# File test/unit/callback_test.rb, line 686
def test_should_call_method_within_the_context_of_the_object
  context = nil
  callback = StateMachine::Callback.new(:around, :do => lambda {|block| context = self; block.call}, :bind_to_object => true)
  callback.call(@object, {}, 1, 2, 3)
  
  assert_equal @object, context
end
test_should_include_arguments_if_specified() click to toggle source
# File test/unit/callback_test.rb, line 694
def test_should_include_arguments_if_specified
  context = nil
  callback = StateMachine::Callback.new(:around, :do => lambda {|*args| block = args.pop; context = args; block.call}, :bind_to_object => true)
  callback.call(@object, {}, 1, 2, 3)
  
  assert_equal [1, 2, 3], context
end