berater 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c5cc50ba02c18bf9ef9f6b9c1dd6ccb8f8af0297df95757ac13406dc4539c40
4
- data.tar.gz: f80341dccff30ca3f344f3bdf21de44b1ef1715bfaf4140933a91252ddb7231e
3
+ metadata.gz: dd61012052d49f83a59057ed5ce4cc46b9c25a2d2bf4b5e494f02e590c2e2249
4
+ data.tar.gz: 3add1b481830566088eb7a9dce3540716b55dda9bb658a7b26b93a261b403f3a
5
5
  SHA512:
6
- metadata.gz: ada3fffc841e71498f652dc990eed482bccc942b86280fc5ee736d49fdf99d8ab2f921b5b52d96f3588c268c34343669c00e0be8822c462a3e6f9dcf954a4005
7
- data.tar.gz: 0363abef69cfdad8140d89373b5088cfa8a6259f16716011c82ceb1e2e9e948cdb4d44ddd36aaf1d05b121dc7d275d0ee34571a0a3ee9b964f4286375ec356cf
6
+ metadata.gz: 476cf552a5fb56498f81a737dba79358d016bedbd76c3c2cc8069c420e82a221c54280781821ef701d25da2551ddc25910818dc400dc7c046cecbe8f6db0ddd2
7
+ data.tar.gz: a92e64f027425ecdc4a39ee5f88a792f4f2625ec4bcf65fac70e34d591fb136e7544caa80138474ae5f5e6158fc19ec8894892585cf858966bfe5fe13a3d011b
@@ -52,7 +52,7 @@ module Berater
52
52
 
53
53
  def self.new(*)
54
54
  # can only call via subclass
55
- raise NotImplementedError if self == Berater::Limiter
55
+ raise NoMethodError if self == Berater::Limiter
56
56
 
57
57
  super
58
58
  end
@@ -23,7 +23,7 @@ module Berater
23
23
  e = self.class.constants.map do |name|
24
24
  self.class.const_get(name)
25
25
  end.find do |const|
26
- const < Berater::Overloaded
26
+ const.is_a?(Class) && const < Berater::Overloaded
27
27
  end || Berater::Overloaded
28
28
 
29
29
  raise e
@@ -1,3 +1,3 @@
1
1
  module Berater
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
data/spec/limiter_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  describe Berater::Limiter do
2
2
  it 'can not be initialized' do
3
- expect { described_class.new }.to raise_error(NotImplementedError)
3
+ expect { described_class.new }.to raise_error(NoMethodError)
4
4
  end
5
5
 
6
6
  describe 'abstract methods' do
@@ -12,7 +12,43 @@ describe Berater::Limiter do
12
12
  end
13
13
  end
14
14
 
15
- describe '==' do
15
+ describe '#limit' do
16
+ subject { Berater::Unlimiter.new }
17
+
18
+ context 'with a capacity parameter' do
19
+ it 'overrides the stored value' do
20
+ is_expected.to receive(:acquire_lock).with(3, anything)
21
+
22
+ subject.limit(capacity: 3)
23
+ end
24
+
25
+ it 'validates the type' do
26
+ expect {
27
+ subject.limit(capacity: 'abc')
28
+ }.to raise_error(ArgumentError)
29
+ end
30
+ end
31
+
32
+ context 'with a cost parameter' do
33
+ it 'overrides the stored value' do
34
+ is_expected.to receive(:acquire_lock).with(anything, 2)
35
+
36
+ subject.limit(cost: 2)
37
+ end
38
+
39
+ it 'validates' do
40
+ expect {
41
+ subject.limit(cost: 'abc')
42
+ }.to raise_error(ArgumentError)
43
+
44
+ expect {
45
+ subject.limit(cost: -1)
46
+ }.to raise_error(ArgumentError)
47
+ end
48
+ end
49
+ end
50
+
51
+ describe '#==' do
16
52
  let(:limiter) { Berater::RateLimiter.new(:key, 1, :second) }
17
53
 
18
54
  it 'equals itself' do
@@ -18,7 +18,7 @@ describe Berater::TestMode do
18
18
  end
19
19
 
20
20
  it 'preserves the original functionality via super' do
21
- expect { Berater::Limiter.new }.to raise_error(NotImplementedError)
21
+ expect { Berater::Limiter.new }.to raise_error(NoMethodError)
22
22
  end
23
23
  end
24
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis