Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
Created February 17, 2015 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmcarthur/09db3280097084165a1a to your computer and use it in GitHub Desktop.
Save joshmcarthur/09db3280097084165a1a to your computer and use it in GitHub Desktop.
# Like rspec --format doc, (which minitest doesn't have)
#
# usage: minidoc test/integration/robs_cool_potatoes_test.rb
minidoc() {
rscript='
red = "\e[0;31m"
purple = "\e[0;35m"
green = "\e[0;32m"
blue = "\e[0;34m"
none = "\e[0m"
should_test = /^(\s*should)/
context_test = /^(\s*context)/
if $_ =~ should_test || $_ =~ context_test
coloured_line = $_.gsub(context_test,"#{green}\\1#{none}").gsub(should_test,"#{blue}\\1#{none}")
puts coloured_line
end'
cat -n "$1" | ruby -n -e "$rscript"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment