Created
October 1, 2022 06:52
-
-
Save okonomi/12fc0efcc3aa07e86f1c0dbd433f7c2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "rspec" | |
end | |
require "rspec/autorun" | |
RSpec.describe "method double test" do | |
class App | |
def foo(*args, **kwargs) | |
bar(*args, **kwargs) | |
end | |
def bar(*args, **kwargs) | |
p args, kwargs | |
end | |
end | |
it "with kwargs" do | |
app = App.new | |
expect(app).to receive(:bar).with("arg", a: :b) | |
app.foo("arg", a: :b) | |
end | |
it "without kwargs" do | |
app = App.new | |
# expect(app).to receive(:bar).with("arg") | |
expect(app).to receive(:bar).with("arg", **{}) | |
app.foo("arg") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment