-
-
Save edavis10/46695 to your computer and use it in GitHub Desktop.
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
#!/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