class CallbackWithAroundTypeAndArgumentsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/callback_test.rb, line 642
def setup
  @object = Object.new
end
test_should_include_arguments_if_specified() click to toggle source
# File test/unit/callback_test.rb, line 652
def test_should_include_arguments_if_specified
  callback = StateMachine::Callback.new(:around, lambda {|object, arg1, arg2, arg3, block| @args = [object, arg1, arg2, arg3]; block.call})
  callback.call(@object, {}, 1, 2, 3)
  assert_equal [@object, 1, 2, 3], @args
end
test_should_include_arguments_if_splat_used() click to toggle source
# File test/unit/callback_test.rb, line 658
def test_should_include_arguments_if_splat_used
  callback = StateMachine::Callback.new(:around, lambda {|*args| block = args.pop; @args = args; block.call})
  callback.call(@object, {}, 1, 2, 3)
  assert_equal [@object, 1, 2, 3], @args
end
test_should_include_object_if_specified() click to toggle source
# File test/unit/callback_test.rb, line 646
def test_should_include_object_if_specified
  callback = StateMachine::Callback.new(:around, lambda {|object, block| @args = [object]; block.call})
  callback.call(@object)
  assert_equal [@object], @args
end