Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

rspec I/O for a ruby script

View script_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
require 'open3'
 
describe 'my_script' do
def run *args
options = args.extract_options!
args.unshift './my_script'
 
Open3.popen3(args.join(' ')) do |i, o, e|
i.write options[:stdin]
i.close
[o, e].map{|pipe|pipe.read.strip}
end
end
 
it "should echo STDIN" do
out, err = run :stdin => 'foo'
out.should == 'foo'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.