Skip to content

Commit 8028216

Browse files
committed
Add spec coverage on CommandLineRunner
1 parent dfdc557 commit 8028216

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require "spec_helper"
2+
require "cc/engine/duplication"
3+
4+
module CC::Engine::Analyzers
5+
RSpec.describe CommandLineRunner do
6+
describe "#run" do
7+
it "runs the command on the input and yields the output" do
8+
runner = CommandLineRunner.new("cat; echo hi")
9+
10+
output = runner.run("oh ") { |o| o }
11+
12+
expect(output).to eq "oh hi\n"
13+
end
14+
15+
16+
it "raises on errors" do
17+
runner = CommandLineRunner.new("echo error output >&2; false")
18+
19+
expect { runner.run("") }.to raise_error(
20+
ParserError, /code 1:\nerror output/
21+
)
22+
end
23+
24+
it "times out commands" do
25+
runner = CommandLineRunner.new("sleep 3", 0.01)
26+
27+
expect { runner.run("") }.to raise_error(Timeout::Error)
28+
end
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)