Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyword arguments support? #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions spec/after_do_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def one(param)
def two(param1, param2)
param2
end

def kwargs(defd: :default, reqd:)
end
end
end

Expand Down Expand Up @@ -157,6 +160,11 @@ def expect_call_back_error(matcher = nil)
@dummy_class.send callback_adder, :two do mockie.call_method end
dummy_instance.two 5, 8
end

it 'can handle methods with keyword arguments' do
@dummy_class.send callback_adder, :kwargs do mockie.call_method end
dummy_instance.kwargs defd: :def, reqd: :req
end
end

describe 'with parameters for the given block' do
Expand All @@ -171,6 +179,14 @@ def expect_call_back_error(matcher = nil)
@dummy_class.send callback_adder, :two do |i, j| mockie.call_method i, j end
dummy_instance.two 5, 8
end

it 'can handle keyword arguments' do
expect(mockie).to receive(:call_method).with(defd: :def, reqd: :req)
@dummy_class.send callback_adder, :kwargs do |args|
mockie.call_method defd: args[:defd], reqd: args[:reqd]
end
dummy_instance.kwargs defd: :def, reqd: :req
end
end

describe 'multiple methods' do
Expand Down