Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created May 17, 2013 15:15
Show Gist options
  • Save thinkerbot/5599737 to your computer and use it in GitHub Desktop.
Save thinkerbot/5599737 to your computer and use it in GitHub Desktop.
Stubbing on the command line.
#!/bin/sh
cat > example <<"DOC"
#!/usr/bin/env ruby
puts "got: #{`git log | head -n 1`}"
DOC
chmod +x example
test_example () {
./example | grep "got: commit [[:xdigit:]]\{40\}"
}
test_example_with_stub () {
git () {
echo abc
}
export -f git
./example | assert_output "\
got: abc
"
}
. ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment