dhc 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbcbbfbe466771c1ad389aebe29d997915137216b50b0aceff73f3cbc589f050
4
- data.tar.gz: a659a0b022d803a700352d20fe96482731470b31234e8db9df3f665da5547ae7
3
+ metadata.gz: 0f70dd2da0d8ec740cf21499fc95ba815a73730c2e1c6a4b8cfef6ff18eef0ce
4
+ data.tar.gz: b0773620c07f30f040439d1c56c7a144ee2f144eb0d987d885aec2b940367b6a
5
5
  SHA512:
6
- metadata.gz: 1851454238cb9552457a56c020edcb88b8b7e37eed6ebc0c6d1a8574c8250c520cfd48d8ca1e9f82ddcd334085daf1651fb0c31221ea638921aeb5873218846f
7
- data.tar.gz: 4432965dcb69081d1d082cfc47101644a817f387d79213f57b8d2b80192901148e49b6a9ceb4ddb10c632e425385b30026de4c2bbbe69ffdaeefb5bf105c6bf5
6
+ metadata.gz: 3c652d89a8d1dcbeadf72472322881ce136692d1b51630c61f4cf0b058ff96d9ded1345c80238fa5d46599d494328ebaecc007a915283eae1971efe89de8cea6
7
+ data.tar.gz: 9f71766d909205e3771cd2cfd65130458ac6a73bf35119bd6edf83f1de1ecba418611b66544affd4572b4b275641875d6ae6507fd4a4d07ad1609ae263ff1694
@@ -59,7 +59,7 @@ class DHC::Throttle < DHC::Interceptor
59
59
  remaining = tracker[:remaining] * 100
60
60
  limit = tracker[:limit]
61
61
  remaining_quota = 100 - options[:break].to_i
62
- remaining < remaining_quota * limit
62
+ remaining <= remaining_quota * limit
63
63
  end
64
64
  end
65
65
 
data/lib/dhc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHC
4
- VERSION ||= '2.2.0'
4
+ VERSION ||= '2.2.1'
5
5
  end
@@ -33,11 +33,11 @@ describe DHC::Throttle do
33
33
  end
34
34
 
35
35
  context 'breaks' do
36
- let(:quota_limit) { 10 }
36
+ let(:quota_limit) { 100 }
37
37
  let(:break_after) { '79%' }
38
38
 
39
39
  it 'hit the breaks if throttling quota is reached' do
40
- 8.times do
40
+ 79.times do
41
41
  DHC.get('http://depay.fi', options)
42
42
  end
43
43
  expect { DHC.get('http://depay.fi', options) }.to raise_error(
@@ -50,19 +50,29 @@ describe DHC::Throttle do
50
50
  let(:break_after) { '80%' }
51
51
 
52
52
  it 'does not hit the breaks' do
53
- 9.times do
53
+ 80.times do
54
54
  DHC.get('http://depay.fi', options)
55
55
  end
56
56
  end
57
+
58
+ it 'does hit the breaks surpassing quota' do
59
+ 80.times do
60
+ DHC.get('http://depay.fi', options)
61
+ end
62
+ expect { DHC.get('http://depay.fi', options) }.to raise_error(
63
+ DHC::Throttle::OutOfQuota,
64
+ 'Reached predefined quota for depay.fi'
65
+ )
66
+ end
57
67
  end
58
68
  end
59
69
 
60
70
  context 'expires' do
61
71
  let(:break_after) { '80%' }
62
- let(:quota_limit) { 10 }
72
+ let(:quota_limit) { 100 }
63
73
 
64
74
  it 'attempts another request if the quota expired' do
65
- 9.times do
75
+ 80.times do
66
76
  DHC.get('http://depay.fi', options)
67
77
  end
68
78
  expect { DHC.get('http://depay.fi', options) }.to raise_error(
@@ -70,7 +80,7 @@ describe DHC::Throttle do
70
80
  'Reached predefined quota for depay.fi'
71
81
  )
72
82
  Timecop.travel(Time.zone.now + 1.minute)
73
- 9.times do
83
+ 80.times do
74
84
  DHC.get('http://depay.fi', options)
75
85
  end
76
86
  expect { DHC.get('http://depay.fi', options) }.to raise_error(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/DePayFi/dhc/contributors