zaphod

Catch untested commits and report them.


License
EPL-1.0
Install
gem install zaphod -v 1.1.0

Documentation

Zaphod

“I can understand that. I wouldn’t trust myself further than I could spit a rat.”

You Will Not Commit Untested Code!

Catch, and publicly embarrass, untested commits into git.

Zaphod is a formatter for SimpleCov that compares the current git changes with the uncovered source reported by SimpleCov. If any source code appears both in the uncovered code and git changes, Zaphod will call an #on_failure hook. By default, this exits and fails the build.

Installation

Simple Installation

require "zaphod"
Zaphod.setup

This will set up the Zaphod formatter and start SimpleCov.

It is equivalent to the following:

require "zaphod"

SimpleCov.formatters = [
  SimpleCov::Formatter::HTMLFormatter,
  SimpleCov::Formatter::ZaphodFormatter
]

SimpleCov.start

Be certain that SimpleCov is started before any of your project’s source is loaded.

Setup your own SimpleCov Formatters

require "zaphod"

SimpleCov.formatters = [
  SimpleCov::Formatter::HTMLFormatter,  # Optional, I suppose
  SimpleCov::Formatter::ZaphodFormatter
]

SimpleCov.start

Configuration

require "pony"             # https://github.com/benprew/pony

Zaphod.setup do |configuration|
  # Action to take if uncovered changes are found:
  configuration.on_failure do |uncovered_changes|
    Pony.mail(
      to: 'your-team@example.com',
      subject: "Someone is trying to commit untested code!",
      body: uncovered_changes.to_s
      )
    exit -1 # Abort the build with a failing exit code
  end
end

Alternatively, you can set up Zaphod separately from SimpleCov:

SimpleCov.formatters = [
  SimpleCov::Formatter::HTMLFormatter,
  SimpleCov::Formatter::ZaphodFormatter
]

Zaphod.configure do |configuration|
  configuration.on_failure do |uncovered_changes|
    $stderr.puts "What would your mother think?"
    exit -1
  end
end
SimpleCov.start

Dependencies

  • Git
  • SimpleCov