berater 0.6.1 → 0.6.2
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 +4 -4
 - data/lib/berater/limiter.rb +1 -1
 - data/lib/berater/test_mode.rb +1 -1
 - data/lib/berater/version.rb +1 -1
 - data/spec/limiter_spec.rb +38 -2
 - data/spec/test_mode_spec.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: dd61012052d49f83a59057ed5ce4cc46b9c25a2d2bf4b5e494f02e590c2e2249
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3add1b481830566088eb7a9dce3540716b55dda9bb658a7b26b93a261b403f3a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 476cf552a5fb56498f81a737dba79358d016bedbd76c3c2cc8069c420e82a221c54280781821ef701d25da2551ddc25910818dc400dc7c046cecbe8f6db0ddd2
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a92e64f027425ecdc4a39ee5f88a792f4f2625ec4bcf65fac70e34d591fb136e7544caa80138474ae5f5e6158fc19ec8894892585cf858966bfe5fe13a3d011b
         
     | 
    
        data/lib/berater/limiter.rb
    CHANGED
    
    
    
        data/lib/berater/test_mode.rb
    CHANGED
    
    
    
        data/lib/berater/version.rb
    CHANGED
    
    
    
        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( 
     | 
| 
      
 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 ' 
     | 
| 
      
 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
         
     | 
    
        data/spec/test_mode_spec.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-03-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: redis
         
     |