Skip to content

Instantly share code, notes, and snippets.

@codahale
Created January 13, 2009 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codahale/46692 to your computer and use it in GitHub Desktop.
Save codahale/46692 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Written by Coda Hale <coda.hale@gmail.com>. MIT License. Go for it.
def include_pattern(filename)
core = filename.gsub(/_spec/, "").gsub(/\Aspec\//, "")
return Regexp.quote(core)
end
if ARGV.empty? || ARGV == ["--help"] || ARGV == ["-h"]
STDERR.puts("Usage:")
STDERR.puts(" spec-and-coverage spec/models/example_spec.rb --color --other-rspec-option")
exit(-1)
else
exec(
"rcov",
"-T", # generate a text summary
"--no-html", # don't generate HTML
"-o", "/dev/null", # don't generate anything
"-x", ".*", # exclude everything
"-i", include_pattern(ARGV.first), # but include the file under test
ARGV.first, # run the spec
"--", *ARGV[1..-1]) # and pass on any options to the spec
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment