Sha256: 8ba82da8c1bed3dc94d2d0ad72e6fb860facf59f473f4e804398b2244ef1d057

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'helper'

describe Feedlr::RateLimit do

  describe '#count' do
    it 'returns an Integer when x-ratelimit-count header is set' do
      rate_limit = Feedlr::RateLimit.new('x-ratelimit-count' => '149')
      expect(rate_limit.count).to be_an Integer
      expect(rate_limit.count).to eq(149)
    end
    it 'returns nil when x-ratelimit-count header is not set' do
      rate_limit = Feedlr::RateLimit.new
      expect(rate_limit.count).to be_nil
    end
  end

  describe '#limit' do
    it 'returns an Integer when x-ratelimit-limit header is set' do
      rate_limit = Feedlr::RateLimit.new('x-ratelimit-limit' => '150')
      expect(rate_limit.limit).to be_an Integer
      expect(rate_limit.limit).to eq(150)
    end
    it 'returns nil when x-ratelimit-limit header is not set' do
      rate_limit = Feedlr::RateLimit.new
      expect(rate_limit.limit).to be_nil
    end
  end

  describe '#remaining' do
    it 'returns an Integer when x-ratelimit-remaining header is set' do
      rate_limit = Feedlr::RateLimit.new('x-ratelimit-remaining' => '149')
      expect(rate_limit.remaining).to be_an Integer
      expect(rate_limit.remaining).to eq(149)
    end
    it 'returns nil when x-ratelimit-remaining header is not set' do
      rate_limit = Feedlr::RateLimit.new
      expect(rate_limit.remaining).to be_nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feedlr-0.1.0 spec/feedly/rate_limit_spec.rb