Sha256: 3597c558994149a48d88d97116b496877b3461b542ff5d064f6d723e6394e2bb
Contents?: true
Size: 970 Bytes
Versions: 14
Compression:
Stored size: 970 Bytes
Contents
require_relative '../../test_helper' class CallbackWithBoundMethodAndArgumentsTest < StateMachinesTest def setup @object = Object.new end def test_should_include_single_argument_if_specified context = nil callback = StateMachines::Callback.new(:before, do: lambda { |arg1| context = [arg1] }, bind_to_object: true) callback.call(@object, {}, 1) assert_equal [1], context end def test_should_include_multiple_arguments_if_specified context = nil callback = StateMachines::Callback.new(:before, do: lambda { |arg1, arg2, arg3| context = [arg1, arg2, arg3] }, bind_to_object: true) callback.call(@object, {}, 1, 2, 3) assert_equal [1, 2, 3], context end def test_should_include_arguments_if_splat_used context = nil callback = StateMachines::Callback.new(:before, do: lambda { |*args| context = args }, bind_to_object: true) callback.call(@object, {}, 1, 2, 3) assert_equal [1, 2, 3], context end end
Version data entries
14 entries across 14 versions & 2 rubygems