2016年9月16日金曜日

開発環境

Head First Ruby (Jay McGavren (著)、O'Reilly Media)のChapter 13.(Unit Testing: Code Quality Assurance)、Updating our code to use the "setup" method、POOL PUZZLE(No. 6913)を取り組んでみる。

POOL PUZZLE(No. 6913)

コード(Emacs)

#!/usr/bin/env ruby2.3
# -*- coding: utf-8 -*-

require 'minitest/autorun'

class TestArray < Minitest::Test
  def setup
    @array = ['a', 'b', 'c']
  end

  def test_length
    assert_equal(3, @array.length)
  end

  def test_last
    assert_equal('c', @array.last)
  end

  def test_join
    assert_equal('a-b-c', @array.join('-'))
  end

end

入出力結果(Terminal)

$ ./sample2.rb
Run options: --seed 64943

# Running:

...

Finished in 0.005030s, 596.4351 runs/s, 596.4351 assertions/s.

3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
$

0 コメント:

コメントを投稿

Comments on Google+: