こんにちは、私はRubyを完全に新しくしています。 Minitestsを実行しようとしていますが、CountDownクラスにコンストラクタを追加するまでうまく動作します。ここでRuby Minitest 0テスト
はコードです:
require 'benchmark'
require 'minitest/autorun'
#! /usr/bin/env ruby
#This is our countdown class
# :reek:DuplicateMethodCall
# :reek:TooManyStatements
class CountDown
def initialize(time)
@time = time
end
def count()
wait_time = @time.to_i
print wait_time.to_s + " seconds left\n"
sleep 1
wait_time = wait_time - 1
wait_time.downto(1).each do |time_left|
sleep 1
print time_left.to_s + " seconds left\n" if (time_left % 60) == 0
end
print "\a"
end
end
#This class is responsible for our test cases
class CountDownTest < Minitest::Test
def setup
@count_down = CountDown.new(10)
end
def testing_lowerbound
time = Benchmark.measure{
@count_down.count
}
assert time.real.to_i == 10
end
end
この私の私の出力:
チームシティー[enteredTheMatrixのタイムスタンプ= '2017-09-28T15:10:11.470から0700']
チームシップ[testCountカウント= '0'タイムスタンプ= '2017-09-28T15:10:11.471-0700'] 0.00038s 0テストで完了、0 アサーション、0失敗、0エラー、0スキップ
プロセスは終了コード0で終了しました
何が問題なのですか?それは私にはうまく見えます。
Rubyは引数リストが空であればそれを避けるのが一般的ですから、ここでは 'def count'で十分です。電話するときも同じです。 Rubyは多くの場合、メソッドをかなり積極的に連鎖させるので、これは多くの混乱を減らすことができます。 – tadman