Skip to content

Commit

Permalink
Change timeout tests to use infinite fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Nov 11, 2017
1 parent 4fb04e2 commit 77a7068
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions spec/fixtures/infinite
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

loop do
puts 'hello'
end
6 changes: 4 additions & 2 deletions spec/unit/timeout_spec.rb
Expand Up @@ -2,18 +2,20 @@

RSpec.describe TTY::Command, '#run' do
it "times out after a specified period" do
infinite = tmp_path('infinite')
output = StringIO.new
cmd = TTY::Command.new(output: output)
expect {
cmd.run("while test 1; do echo 'hello'; sleep 0.1; done", timeout: 0.1)
cmd.run("ruby #{infinite}", timeout: 0.1)
}.to raise_error(TTY::Command::TimeoutExceeded)
end

it "times out globally all commands" do
infinite = tmp_path('infinite')
output = StringIO.new
cmd = TTY::Command.new(output: output, timeout: 0.1)
expect {
cmd.run("while test 1; do echo 'hello'; sleep 0.1; done")
cmd.run("ruby #{infinite}")
}.to raise_error(TTY::Command::TimeoutExceeded)
end

Expand Down

0 comments on commit 77a7068

Please sign in to comment.