Created
May 17, 2013 15:15
-
-
Save thinkerbot/5599737 to your computer and use it in GitHub Desktop.
Stubbing on the command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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