Sha256: 380c6d7b0fe844c2b179bc9db8a251f5ce94fc87736e94b54875b08a1b90ef30

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 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::interval(0)
    assert_equal 6, Polling::Target::interval(5)
    assert_equal 0, Polling::Target::interval(59)
    assert_equal 1, Polling::Target::interval(60)
    assert_equal 2, Polling::Target::interval(61)

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polling-0.0.3 test/test_target.rb