Sha256: fa470e1c2affb1a22f513e7d8b0687fd93691bb89465efe709f0b553e1f4a445

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

require File.expand_path(File.dirname(__FILE__)) + "/helper.rb"
require 'time'

class PollingTest < Test::Unit::TestCase

  def test_target_time
    Time.stubs(:now).returns(Time.parse "2012/12/31 23:59:59")
    assert_equal 1, Polling::Target::create_time(0)
    assert_equal 6, Polling::Target::create_time(5)
    assert_equal 0, Polling::Target::create_time(59)
    assert_equal 1, Polling::Target::create_time(60)
    assert_equal 2, Polling::Target::create_time(61)

    arr = [0,1,5,10,20,30,40,50,58]
    arr.each do |time|
      assert_equal time+1, Polling::Target::create_time(time)
    end

    Time.stubs(:now).returns(Time.parse "2012/01/01 00:00:00")
    assert_equal 180, Polling::Target::create_time(180,true)
    assert_equal 300, Polling::Target::create_time(300,true)
    assert_equal 300, Polling::Target::create_time(300,true)
    assert_equal 3600, Polling::Target::create_time(3600,true)

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polling-0.0.2 test/test_target.rb