Intro to TDD with Ruby's minitest

See also: https://semaphoreci.com/community/tutorials/getting-started-with-minitest

Requisites

We're going to implement a small unicorn class with these requirements:

Setup

This will install minitest globally:

gem install minitest

Creating projects dir/files:

mkdir unicorn
cd unicorn
touch unicorn_test.rb
touch unicorn.rb
# configuring minitest:
gem 'minitest', '~> 5.0'
require 'minitest/autorun'
require 'minitest/pride' # colors! :)

# loading the class we want to test
require_relative 'unicorn'

# starting the test suite
class UnicornTest < Minitest::Test
end

To run the test:

ruby unicorn_test.rb

Assertions

docs

Skipping a Test

A test can be skipped with skip.

Example:

def test_something_else
  skip
  assert_equal 1, nil - 1
end