testowl 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/testowl/teeio.rb +49 -0
- data/lib/testowl/version.rb +1 -1
- data/testowl.gemspec +1 -0
- metadata +4 -3
@@ -0,0 +1,49 @@
|
|
1
|
+
# Teeio has two approaches to capturing output and this single class
|
2
|
+
# attempts to do both - smudged, wedged and shoved into one. The problem
|
3
|
+
# we're solving here is how to get the output from the tests streamed to
|
4
|
+
# stdout while still being able to capture the output for analysis.
|
5
|
+
# Doing a simple backtick means that we're not able to provide feedback
|
6
|
+
# on progress until the tests are finished.
|
7
|
+
#
|
8
|
+
# If you call run then it will pipe the ouput, via tee, to a temporary
|
9
|
+
# file and then read that file to get the output.
|
10
|
+
#
|
11
|
+
# You can also pass an instance of this class for objects that expect
|
12
|
+
# stdio and it will probably work, in a duck-typing fashion. At least,
|
13
|
+
# it works with Spork - which is what we're interested in.
|
14
|
+
module TestOwl
|
15
|
+
class Teeio
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@results = []
|
19
|
+
@file = Tempfile.new('testowl')
|
20
|
+
end
|
21
|
+
|
22
|
+
def run(command)
|
23
|
+
system("#{command} | tee #{@file.path}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def write(buf)
|
27
|
+
@results << buf
|
28
|
+
$stdout.write buf
|
29
|
+
end
|
30
|
+
|
31
|
+
def puts(buf)
|
32
|
+
@results << buf
|
33
|
+
$stdout.puts buf
|
34
|
+
end
|
35
|
+
|
36
|
+
def flush
|
37
|
+
$stdout.flush
|
38
|
+
end
|
39
|
+
|
40
|
+
def output
|
41
|
+
if @results.size == 0
|
42
|
+
IO.read(@file.path)
|
43
|
+
else
|
44
|
+
@results.join
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
data/lib/testowl/version.rb
CHANGED
data/testowl.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testowl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bill Horsman
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/testowl/growl.rb
|
69
69
|
- lib/testowl/monitor.rb
|
70
70
|
- lib/testowl/rspec_runner.rb
|
71
|
+
- lib/testowl/teeio.rb
|
71
72
|
- lib/testowl/test_unit_runner.rb
|
72
73
|
- lib/testowl/tester.rb
|
73
74
|
- lib/testowl/version.rb
|