Skip to content

Instantly share code, notes, and snippets.

@acook
Created August 26, 2011 12:23
Show Gist options
  • Save acook/1173299 to your computer and use it in GitHub Desktop.
Save acook/1173299 to your computer and use it in GitHub Desktop.
A spec_helper to assist in testing executable file behaviour, assumes your Gemfile includes the Open4 gem.
require 'bundler'
Bundler.require(:test)
def run(*args)
output = Struct.new(:pid, :stdout, :stderr)
status = Open4.popen4(*args) do |pid, stdin, stdout, stderr|
output = output.new pid, stdout.read, stderr.read
end
[status, output]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment