Railsメモ【minitest reporters】minitestでREDやGREENを表示する方法

Railsチュートリアルで学んだことをメモ

minitestの際に、成功/失敗の結果を緑/赤でわかりやすく表示する方法

参考
Ruby on Rails チュートリアル:実例を使って Rails を学ぼう
Ruby on Rails ガイド:体系的に Rails を学ぼう

Gemfileのテストグループにgem 'minitest-reporters' を追加する

[Gemfile]

group :test do
  gem 'rails-controller-testing', '1.0.2'
  gem 'minitest',                 '5.10.3'
  gem 'minitest-reporters',       '1.1.14'   #追加
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

test_helper.rbに下記変更を加える。

[test/test_helper.rb]

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"     #追加
Minitest::Reporters.use!          #追加

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end