Sha256: 2b5e5c7554a2dfa7eb078042c4ca516ae6458940b8b41962a4535ec88a759da0

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

require 'helper'

class TestRateLimited < Test::Unit::TestCase

  context Prop::RateLimited do
    context "#initialize" do
      setup do
        time = Time.at(1333685680)
        Time.stubs(:now).returns(time)

        @error = Prop::RateLimited.new(:handle => "foo", :threshold => 10, :interval => 60, :cache_key => "wibble", :description => "Boom!")
      end

      should "return an error instance" do
        assert @error.is_a?(StandardError)
        assert @error.is_a?(Prop::RateLimited)

        assert_equal "foo", @error.handle
        assert_equal "wibble", @error.cache_key
        assert_equal "Boom!", @error.description
        assert_equal "foo threshold of 10 tries per 60s exceeded for key 'nil', hash wibble", @error.message
        assert_equal 20, @error.retry_after
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prop-1.0.0 test/test_rate_limited.rb
prop-0.7.8 test/test_rate_limited.rb