Simple Minitest reporter to indicate the result of test runs in as fancy a way you like. Here's how I like it: Flash the screen in green or red and play a short sound effect.
- Homepage
- Author: Sven Schwyn - Bitcetera
Thank you for supporting free and open-source software by sponsoring on GitHub or on Donorbox. Any gesture is appreciated, from a single Euro for a ☕️ cup of coffee to 🍹 early retirement.
Add the following to the Gemfile or gems.rb of your Bundler powered Ruby project:
gem 'minitest-flash'And then install the bundle:
bundle install
Finally, require this gem in your test_helper.rb or spec_helper.rb:
require 'minitest/flash'After every test run, the reporter simply invokes the minitest-flash executable:
minitest-flash greenif the run passedminitest-flash redif the run failed or has errors
It's your job to create the minitest-flash executable to your liking and to place it somewhere in the PATH.
Other people might work on the same code and prefer not use minitest-flash. This is no problem as it won't do a thing unless a minitest-flash executable exists.
I'm on macOS and like things to be as obvious and unobtrusive as possible: Flash the screen border either in green or red and optionally play a sound effect.
Here's what my /usr/local/bin/minitest-flash executable looks like:
#!/bin/zsh
typeset -A flash_args
flash_args=(
[green]="0 200 0 8 2"
[red]="200 0 0 8 2"
)
if [ -z "$MINITEST_NO_FLASH" ]; then
border-flash ${=flash_args[$1]} &
fi
if [ -z "$MINITEST_NO_SOUND" ]; then
mpg123 $0.d/$1.mp3 2>/dev/null &
fiAs you see, the sound or flash effects can easily be muted with:
export MINITEST_NO_FLASH=1
export MINITEST_NO_SOUND=1For the above to work, you have to install the following additional tools and files.
Follow the simple install instructions of border-flash.
This is easiest installed through Homebrew:
brew install mpg123The sound files are also necessary:
sudo mkdir /usr/local/bin/minitest-flash.d
sudo wget -P /usr/local/bin/minitest-flash.d/green.mp3 https://github.com/svoop/minitest-flash/raw/main/doc/green.mp3
sudo wget -O /usr/local/bin/minitest-flash.d/red.mp3 https://github.com/svoop/minitest-flash/raw/main/doc/red.mp3To install the development dependencies and then run the test suite:
bundle install
bundle exec rake # run tests once
bundle exec guard # run tests whenever files are modified
You're welcome to submit issues and contribute code by forking the project and submitting pull requests.
The gem is available as open source under the terms of the MIT License.
