blue-shell 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -77,7 +77,10 @@ module BlueShell
77
77
  end
78
78
 
79
79
  def output_ended?(timeout)
80
- (@out.is_a?(IO) && !IO.select([@out], nil, nil, timeout)) || @out.eof?
80
+ timeout.to_i.times do
81
+ return true if (@out.is_a?(IO) && !IO.select([@out], nil, nil, 1)) || @out.eof?
82
+ end
83
+ false
81
84
  end
82
85
  end
83
86
  end
@@ -1,3 +1,3 @@
1
1
  module BlueShell
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.1.0".freeze
3
3
  end
@@ -21,4 +21,22 @@ describe BlueShell::BufferedReaderExpector do
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ describe "output_ended?" do
26
+ it "should not wait the full timeout if the command has already exited" do
27
+ begin_time = Time.now
28
+ Thread.new() do
29
+ sleep(2)
30
+ write.puts Net::EOF
31
+ end
32
+ subject.send(:output_ended?, 10)
33
+ duration = Time.now - begin_time
34
+
35
+ duration.should <= 5
36
+ end
37
+
38
+ it "should handle non-integer timeouts" do
39
+ expect { subject.send(:output_ended?, 0.1) }.to_not raise_error
40
+ end
41
+ end
24
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-12 00:00:00.000000000 Z
13
+ date: 2013-04-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec