Sha256: 22e7cff5987cf87b947b778a82d6815d760a2d0d1c1be3ad95f38413c85b3c8f

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

require 'io/grab'
require 'stringio'

describe "IO#grab" do
  let(:io) { StringIO.new }

  it "catches the output correctly" do
    io.grab { io.puts "foo" }.should == "foo\n"
  end

  it "doesn't pass the output to the original implementation" do
    io.grab { io.puts "foo" }
    io.string.should be_empty
  end

  it "reverts the grab when it's done" do
    io.grab { io.puts "foo" }
    io.puts "bar"
    io.string.should == "bar\n"
  end

  it "works for STDOUT" do
    STDOUT.grab { puts "foo" }.should == "foo\n"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
io-grab-0.0.2 spec/io-grab_spec.rb
io-grab-0.0.1 spec/io-grab_spec.rb