hand test.rb
code:ruby
require 'minitest/autorun' # require文。使いたいclassの定義を読み込んで準備する
require 'minitest/reporters' # require文。使いたいclassの定義を読み込んで準備する
# コメントアウトしてある行を入れ替えて、HtmlReporter.newを有効に、SpecReporter.newを無効にすると、
# ブラウザから読み取れるhtml形式で結果レポートを出力することができる
Minitest::Reporters.use! Minitest::Reporters::HtmlReporter.new
require_relative '../lib/hand.rb' # require文の仲間。使いたいclassの定義を読み込んで準備する
class HandTest < Minitest::Test # Minitestを継承して、テストに役立つ機能を用意
def test_high_card # テストの名前を定義
assert_equal 'high-card', hand.rank # hand.rankで表示される役が期待と一致するかチェック
end
# 以下、与えるトランプと役が違うだけで同じことの繰り返し
def test_one_pair
assert_equal 'one-pair', hand.rank
end
def test_two_pair
assert_equal 'two-pair', hand.rank
end
def test_three_of_a_kind
assert_equal 'three-of-a-kind', hand.rank
end
def test_straight
assert_equal 'straight', hand.rank
end
def test_flush
assert_equal 'flush', hand.rank
end
def test_full_house
assert_equal 'full-house', hand.rank
end
def test_four_of_a_kind
assert_equal 'four-of-a-kind', hand.rank
end
def test_straight_flush
assert_equal 'straight-flush', hand.rank
end
def test_royal_straight_flush
assert_equal 'royal-straight-flush', hand.rank
end
end