stdiotrap 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/stdiotrap.rb +2 -0
- data/lib/stdiotrap/version.rb +1 -1
- data/spec/stdiotrap_spec.rb +10 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -10,7 +10,7 @@ require 'stdiotrap'
|
|
10
10
|
|
11
11
|
describe StdioTrap do
|
12
12
|
|
13
|
-
describe '
|
13
|
+
describe 'Inline usage' do
|
14
14
|
it "captures stdout and stderr" do
|
15
15
|
trapped = StdioTrap.capture {
|
16
16
|
$stdout.puts "Hello world!"
|
@@ -21,7 +21,7 @@ describe StdioTrap do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe '
|
24
|
+
describe 'Common rspec usage' do
|
25
25
|
before :each do
|
26
26
|
StdioTrap.trap!
|
27
27
|
end
|
data/lib/stdiotrap.rb
CHANGED
@@ -14,7 +14,9 @@ module StdioTrap
|
|
14
14
|
def release!(force=false)
|
15
15
|
raise RuntimeError, "Stdio is not currently trapped" if $stdio_trap.nil?
|
16
16
|
raise RuntimeError, "Can not release inside capture{}" if $stdio_trap == :capture and !force
|
17
|
+
r = to_h
|
17
18
|
$stdio_trap, $stdin, $stdout, $stderr = nil, $o_stdin, $o_stdout, $o_stderr
|
19
|
+
r
|
18
20
|
end
|
19
21
|
|
20
22
|
def status
|
data/lib/stdiotrap/version.rb
CHANGED
data/spec/stdiotrap_spec.rb
CHANGED
@@ -61,6 +61,16 @@ describe StdioTrap do
|
|
61
61
|
}
|
62
62
|
}.should raise_error RuntimeError
|
63
63
|
end
|
64
|
+
|
65
|
+
it "returns to_h" do
|
66
|
+
StdioTrap.trap!
|
67
|
+
puts "foo"
|
68
|
+
want = StdioTrap.to_h
|
69
|
+
got = StdioTrap.release!
|
70
|
+
|
71
|
+
got[:stdout].should == "foo\n"
|
72
|
+
want.should == got
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
76
|
describe 'trap!, release!' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stdiotrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
segments:
|
142
142
|
- 0
|
143
|
-
hash:
|
143
|
+
hash: 3851589904731545157
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: 3851589904731545157
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
155
|
rubygems_version: 1.8.23
|