routemaster-drain 1.0.4 → 1.0.5
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/Gemfile.lock +1 -1
- data/lib/routemaster/drain.rb +1 -1
- data/lib/routemaster/redis_broker.rb +1 -2
- data/spec/routemaster/redis_broker_spec.rb +56 -0
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c0272cbd5f92879aa1a44d0b928d5671db23568d
         | 
| 4 | 
            +
              data.tar.gz: a0c52c2160834a7542817358896b2d25cb6adc6a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 265ccd4eaa6f7fdb28f59f5a104b631341bf2858cbd940bef9825eab39539f8fcf64dc9600ccc1470f047f5c2585ead66b1d5b5955fe377e3a479d5e38160df7
         | 
| 7 | 
            +
              data.tar.gz: 6c98dbc0dc65777ed88cc223b36b0ffe2017918481cf1a675b696dc9f5331380725a5f05fe1bb4ebfecfd6878e05bdd8fee23a354e629d18deaa4eb01798a508
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/routemaster/drain.rb
    CHANGED
    
    
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative '../../lib/routemaster/redis_broker'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe Routemaster::RedisBroker do
         | 
| 6 | 
            +
              subject { Class.new(Routemaster::RedisBroker).instance }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              describe "#get" do
         | 
| 9 | 
            +
                let(:url)   { 'redis://localhost/12' }
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                context "setting up a redis namespace" do
         | 
| 12 | 
            +
                  let(:redis)           { instance_double(Redis) }
         | 
| 13 | 
            +
                  let(:redis_namespace) { instance_double(Redis::Namespace) }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  before do
         | 
| 16 | 
            +
                    allow(Redis).to receive(:new) { redis }
         | 
| 17 | 
            +
                    allow(Redis::Namespace).to receive(:new) { redis_namespace }
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  it 'returns a namespaced redis connection' do
         | 
| 21 | 
            +
                    expect(subject.get(url)).to eq(redis_namespace)
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  it 'uses the url to initialise redis' do
         | 
| 25 | 
            +
                    expect(Redis).to receive(:new).with(url: url)
         | 
| 26 | 
            +
                    subject.get(url)
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  it 'namespaces with rm by default' do
         | 
| 30 | 
            +
                    expect(Redis::Namespace).to receive(:new).with('rm', redis: redis)
         | 
| 31 | 
            +
                    subject.get(url)
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  it 'can use a namespace based on the url' do
         | 
| 35 | 
            +
                    expect(Redis::Namespace).to receive(:new).with('other', redis: redis)
         | 
| 36 | 
            +
                    subject.get('redis://localhost/12/other')
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                context "when we are in the same process" do
         | 
| 41 | 
            +
                  it 'is a single connection for each url' do
         | 
| 42 | 
            +
                    expect(subject.get(url)).to eql(subject.get(url))
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                context "when we have forked" do
         | 
| 47 | 
            +
                  let!(:connection) { subject.get(url) }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  it 'is a new connection for the newly forked process' do
         | 
| 50 | 
            +
                    # this is tied to implementation, but tests a 'fork' well enough
         | 
| 51 | 
            +
                    allow(Process).to receive(:pid) { -1 }
         | 
| 52 | 
            +
                    expect(subject.get(url)).to_not eql(connection)
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: routemaster-drain
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Julien Letessier
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-09- | 
| 11 | 
            +
            date: 2015-09-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -192,6 +192,7 @@ files: | |
| 192 192 | 
             
            - spec/routemaster/middleware/filter_spec.rb
         | 
| 193 193 | 
             
            - spec/routemaster/middleware/parse_spec.rb
         | 
| 194 194 | 
             
            - spec/routemaster/middleware/root_post_only_spec.rb
         | 
| 195 | 
            +
            - spec/routemaster/redis_broker_spec.rb
         | 
| 195 196 | 
             
            - spec/spec_helper.rb
         | 
| 196 197 | 
             
            - spec/support/events.rb
         | 
| 197 198 | 
             
            - spec/support/rack_test.rb
         | 
| @@ -239,6 +240,7 @@ test_files: | |
| 239 240 | 
             
            - spec/routemaster/middleware/filter_spec.rb
         | 
| 240 241 | 
             
            - spec/routemaster/middleware/parse_spec.rb
         | 
| 241 242 | 
             
            - spec/routemaster/middleware/root_post_only_spec.rb
         | 
| 243 | 
            +
            - spec/routemaster/redis_broker_spec.rb
         | 
| 242 244 | 
             
            - spec/spec_helper.rb
         | 
| 243 245 | 
             
            - spec/support/events.rb
         | 
| 244 246 | 
             
            - spec/support/rack_test.rb
         |