Sha256: 37176a8dfa7d6adad41937dffb8623e256ed206fdbc51e15ba304dbb02c7f4bb

Contents?: true

Size: 843 Bytes

Versions: 13

Compression:

Stored size: 843 Bytes

Contents

#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), "spec_helper")

require 'spec'
require 'irb'
require File.join(File.dirname(__FILE__), '..', 'lib', 'utility_belt', 'pipe')

describe "String#|" do
  before :each do
    @pipe = stub(:pipe, :write => nil, :close_write => nil, :read => nil)
    IO.stub!(:popen).and_yield(@pipe).and_return("RESULT")
  end

  it "should open a pipe" do
    IO.should_receive(:popen).with("COMMAND", 'r+').and_return(@pipe)
    "foo" | "COMMAND"
  end

  it "should write itself to the the pipe, close it, then read from it" do
    @pipe.should_receive(:write).with("foo").ordered
    @pipe.should_receive(:close_write).ordered
    @pipe.should_receive(:read)

    "foo" | "COMMAND"
  end

  it "should return the result of the IO.popen block" do
    ("foo" | "COMMAND").should == "RESULT"
  end
end

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
FreedomCoder-utility_belt-1.1.1.2 spec/pipe_spec.rb
FreedomCoder-utility_belt-1.1.1 spec/pipe_spec.rb
akitaonrails-utility_belt-1.0.10 spec/pipe_spec.rb
akitaonrails-utility_belt-1.0.11 spec/pipe_spec.rb
akitaonrails-utility_belt-1.0.12 spec/pipe_spec.rb
mguterl-utility_belt-1.0.7 spec/pipe_spec.rb
rwilcox-utility_belt-1.0.7 spec/pipe_spec.rb
rwilcox-utility_belt-1.0.9 spec/pipe_spec.rb
timocratic-utility_belt-1.0.7.1 spec/pipe_spec.rb
timocratic-utility_belt-1.0.7.2 spec/pipe_spec.rb
timocratic-utility_belt-1.0.7.3 spec/pipe_spec.rb
akitaonrails-utility_belt-1.0.13 spec/pipe_spec.rb
utility_belt-1.1.0 spec/pipe_spec.rb