Update test to account for fix in Crystal 1.6

Keyword arguments cannot be used as a short-hand for positional arguments (yet).
https://github.com/icy-arctic-fox/spectator/issues/44
This commit is contained in:
Michael Miller 2022-10-09 12:33:31 -06:00
parent c1e1666449
commit 422b0efa59
No known key found for this signature in database
GPG Key ID: 32B47AE8F388A1FF
1 changed files with 21 additions and 4 deletions

View File

@ -9,12 +9,29 @@ Spectator.describe "GitHub Issue #44" do
let(command) { "ls -l" }
let(exception) { File::NotFoundError.new("File not found", file: "test.file") }
before_each do
expect(Process).to receive(:run).with(command, shell: true, output: :pipe).and_raise(exception)
context "with positional arguments" do
before_each do
pipe = Process::Redirect::Pipe
expect(Process).to receive(:run).with(command, nil, nil, false, true, pipe, pipe, pipe, nil).and_raise(exception)
end
it "must stub Process.run" do
expect do
Process.run(command, shell: true, output: :pipe) do |_process|
end
end.to raise_error(File::NotFoundError, "File not found")
end
end
skip "must stub Process.run", skip: "Method mock not applied" do
Process.run(command, shell: true, output: :pipe) do |_process|
# Original issue uses keyword arguments in place of positional arguments.
context "keyword arguments in place of positional arguments" do
before_each do
expect(Process).to receive(:run).with(command, shell: true, output: :pipe).and_raise(exception)
end
it "must stub Process.run", skip: "Keyword arguments in place of positional arguments not supported with expect-receive" do
Process.run(command, shell: true, output: :pipe) do |_process|
end
end
end
end