Sha256: e3e86e0024923f3df7087875cdcd608b0eed134317d8ce77e79d9712245fc079

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require File.expand_path 'test_helper', File.dirname(__FILE__)

class TestBiteTheDust < MiniTest::Unit::TestCase
  def setup
    @bitethedust = BiteTheDust::BiteTheDust.new(Time.now+5)
    @future = Time.new(2100-01-01)
    @past   = Time.new(1900-01-01)
    @btd_future = BiteTheDust::BiteTheDust.new(@future)
    @btd_past   = BiteTheDust::BiteTheDust.new(@past)
  end

  def test_self_future?
    assert_respond_to BiteTheDust, :future?
    assert_respond_to BTD, :future?
    assert BiteTheDust.future?(@future)
    refute BiteTheDust.future?(@past)
  end

  def test_self_countdown
    assert_respond_to BiteTheDust, :countdown
    assert_respond_to BTD, :countdown
    assert_equal "done", BiteTheDust.countdown(2){|n| "done"}
  end

  def test_initialize
    assert_raises(ArgumentError) { BiteTheDust::BiteTheDust.new }
    assert_instance_of BiteTheDust::BiteTheDust, BiteTheDust::BiteTheDust.new(Time.new(2100-01-01))
  end

  def test_future?
    assert_respond_to(@bitethedust, :future?)
    assert @btd_future.future?
    refute @btd_past.future?
  end

  def test_set_timer
    assert_respond_to(@bitethedust, :set_timer)
    assert_equal "done", @bitethedust.set_timer {|n| "done"}
    assert_equal "done", @btd_past.set_timer {|n| "done"}
    assert_raises RangeError do
      @btd_future.set_timer {|n| "done"}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bite_the_dust-0.0.2 test/test_bite_the_dust.rb