mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Reenable test for https://github.com/icy-arctic-fox/spectator/issues/44 and https://github.com/icy-arctic-fox/spectator/issues/47
40 lines
1.3 KiB
Crystal
40 lines
1.3 KiB
Crystal
require "../spec_helper"
|
|
|
|
Spectator.describe "GitHub Issue #44" do
|
|
inject_mock Process do
|
|
# Instance variable that can be nil, provide a default.
|
|
@process_info = Crystal::System::Process.new(0)
|
|
end
|
|
|
|
let(command) { "ls -l" }
|
|
let(exception) { File::NotFoundError.new("File not found", file: "test.file") }
|
|
|
|
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
|
|
|
|
# Original issue uses keyword arguments in place of positional arguments.
|
|
context "keyword arguments in place of positional arguments" do
|
|
before_each do
|
|
pipe = Process::Redirect::Pipe
|
|
expect(Process).to receive(:run).with(command, shell: true, output: pipe).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
|
|
end
|