Sha256: df7282d093e620865b0f3fd2edc58a0766ce318dc9e4e4e1c8e9c76db661272c
Contents?: true
Size: 1.22 KB
Versions: 11
Compression:
Stored size: 1.22 KB
Contents
require 'assert' require 'cap-util/timer' module CapUtil class TimerTests < Assert::Context desc "the Timer helper class" setup do @timer_util = Timer.new('a timer', :quiet) end subject { @timer_util } should have_readers :name, :start_time, :end_time, :elapsed_time should have_imeths :start, :end should have_cmeth :pretty_time should "know its name" do assert_equal 'a timer', subject.name end should "default its start, end, and elapsed times" do assert_equal 0, subject.start_time assert_equal 0, subject.end_time assert_equal 0, subject.elapsed_time end should "record its start time on `start`" do exp_start_time = ::Time.now subject.start(exp_start_time) assert_equal exp_start_time, subject.start_time end should "record its end and elapsed time on `end`" do exp_start_time = ::Time.now subject.start(exp_start_time) sleep 1 exp_end_time = ::Time.now subject.end(exp_end_time) assert_equal exp_end_time, subject.end_time assert_equal (exp_end_time - exp_start_time), subject.elapsed_time assert_equal "0:01", Timer.pretty_time(subject.elapsed_time.to_i) end end end
Version data entries
11 entries across 11 versions & 1 rubygems