Project

zaphod

0.0
No commit activity in last 3 years
No release in over 3 years
Catch untested commits and report them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.4
>= 0
~> 10.1
~> 1.1
~> 2.14

Runtime

~> 1.2.6
~> 0.8
 Project Readme

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