spec/interceptors/throttle/main_spec.rb in dhc-2.0.1 vs spec/interceptors/throttle/main_spec.rb in dhc-2.1.0
- old
+ new
@@ -23,29 +23,29 @@
}
}
end
before(:each) do
- DHC::Throttle.track = nil
DHC.config.interceptors = [DHC::Throttle]
+ Rails.cache.write(DHC::Throttle::CACHE_KEY, nil)
stub_request(:get, 'http://depay.fi').to_return(
headers: { 'limit' => quota_limit, 'remaining' => quota_remaining, 'reset' => quota_reset }
)
end
it 'tracks the request limits based on response data' do
DHC.get('http://depay.fi', options)
- expect(DHC::Throttle.track[provider][:limit]).to eq quota_limit
- expect(DHC::Throttle.track[provider][:remaining]).to eq quota_remaining
+ expect(Rails.cache.read('DHC/throttle/tracker/v1')[provider][:limit]).to eq quota_limit
+ expect(Rails.cache.read('DHC/throttle/tracker/v1')[provider][:remaining]).to eq quota_remaining
end
context 'fix predefined integer for limit' do
let(:options_limit) { 1000 }
it 'tracks the limit based on initialy provided data' do
DHC.get('http://depay.fi', options)
- expect(DHC::Throttle.track[provider][:limit]).to eq options_limit
+ expect(Rails.cache.read('DHC/throttle/tracker/v1')[provider][:limit]).to eq options_limit
end
end
context 'breaks' do
let(:options_break) { '80%' }