spec/io_spec.rb in darkhelmet-darkext-0.11.2 vs spec/io_spec.rb in darkhelmet-darkext-0.12.0
- old
+ new
@@ -23,8 +23,22 @@
it 'should return nil if not capturing anything' do
DarkIO::capture_output(:stderr => false, :stdout => false) do
STDOUT.print('Hello, World!')
STDERR.print('Hello, World!')
- end.nil?.should == true
+ end.nil?.should be_true
+ end
+
+ it 'should capture output' do
+ HW = 'Hello, World!'
+ out = DarkIO::capture_output { HW.print }
+ out.should == HW
+ out = DarkIO::capture_output(:stderr => true) do
+ (HW + 'STDOUT').print
+ STDERR.print(HW + 'STDERR')
+ end
+ out.shift.should == HW + 'STDOUT'
+ out.shift.should == HW + 'STDERR'
+ out = DarkIO::capture_output(:stderr => true, :stdout => false) { STDERR.print(HW) }
+ out.should == HW
end
end