Minitest::Naga

Welcome! Minitest::Naga is a minitest extension which lets you unlock achievements and collect loot when you run your test suite. This is one half of my disseration project which aims to make unit testing a little bit more fun and to help motivate you to do it. The other part which works in hand with this Ruby gem is the Naga web application. The web app's main purpose is to manage all the (hopefully cool) features of the system as well as the social aspect (e.g. friends and guilds) of Naga.

Installation

Add this line to your application's Gemfile:

gem 'minitest-naga'

And then execute:

$ bundle

Or install it yourself as:

$ gem install minitest-naga

Usage

Firstly, you must sign up in order to use the gem. So if you haven't already, go ahead and do that. I'll wait here...

Back? Cool.

Given you have this file (adapted from the example provided by minitest's GitHub repo):

# a_file_with_lots_of_minitests.rb
require 'minitest/autorun'

class Meme
  def i_can_has_cheezburger?
    "OHAI!"
  end

  def such_wow
    "such wow"
  end

  def will_it_blend?
    "YES!"
  end
end

class TestMeme < Minitest::Test
  def setup
    @meme = Meme.new
  end

  def test_that_kitty_can_eat
    assert_equal "OHAI!", @meme.i_can_has_cheezburger?
  end

  def test_that_cate_can_eat
    assert_equal "OHAI!", @meme.i_can_has_cheezburger?
  end

  def test_that_doggo_can_eat
    assert_equal "OHAI!", @meme.i_can_has_cheezburger?
  end

  def test_that_doge_can_eat
    assert_equal "OHAI!", @meme.i_can_has_cheezburger?
  end

  def test_that_it_will_blend
    assert_equal "YES!", @meme.will_it_blend?
  end

  def test_that_it_will_not_blend
    refute_match /^no/i, @meme.will_it_blend?
  end

  def test_such_wow
    assert_equal "such wow", @meme.such_wow
  end

  def test_that_will_be_skipped
    skip "test this later"
  end
end

To use Naga, just run your test file with the --naga flag:

$ ruby -Ilib:test a_file_with_lots_of_minitests.rb --naga

Alternatively, if you have a directory of test files e.g. in a Rails app:

$ ruby -Ilib:test test/controllers/* --naga

For first timers, you'll be asked to enter your email and password. If you've signed in before, it'll continue to run with that account unless you sign out (see below). Once you've successfully done that, you'll be taken on a weird adventure. So I hope you have fun!

If you don't want to use Naga when running your test suite, just omit the flag like so:

$ ruby -Ilib:test a_file_with_lots_of_minitests.rb

To Sign Out

If you want to sign out, simply run:

$ minitest-naga signout

Wiki

Check out the Wiki for more information about the whole Naga system.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/wtwang1/minitest-naga. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Minitest::Naga project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.