Adjust call argument matching

Reenable test for https://github.com/icy-arctic-fox/spectator/issues/44 and https://github.com/icy-arctic-fox/spectator/issues/47
This commit is contained in:
Michael Miller 2022-11-29 22:31:22 -07:00
parent a967dce241
commit fbe877690d
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 9 additions and 5 deletions

View file

@ -26,12 +26,15 @@ Spectator.describe "GitHub Issue #44" do
# Original issue uses keyword arguments in place of positional arguments. # Original issue uses keyword arguments in place of positional arguments.
context "keyword arguments in place of positional arguments" do context "keyword arguments in place of positional arguments" do
before_each do before_each do
expect(Process).to receive(:run).with(command, shell: true, output: :pipe).and_raise(exception) pipe = Process::Redirect::Pipe
expect(Process).to receive(:run).with(command, shell: true, output: pipe).and_raise(exception)
end end
it "must stub Process.run", skip: "Keyword arguments in place of positional arguments not supported with expect-receive" do it "must stub Process.run" do
expect do
Process.run(command, shell: true, output: :pipe) do |_process| Process.run(command, shell: true, output: :pipe) do |_process|
end end
end.to raise_error(File::NotFoundError, "File not found")
end end
end end
end end

View file

@ -90,9 +90,10 @@ module Spectator
i = 0 i = 0
other.args.each do |k, v2| other.args.each do |k, v2|
break if i >= positional.size
next if kwargs.has_key?(k) # Covered by named arguments. next if kwargs.has_key?(k) # Covered by named arguments.
v1 = positional.fetch(i) { return false } v1 = positional[i]
i += 1 i += 1
return false unless v1 === v2 return false unless v1 === v2
end end