mock_redis 0.23.0 → 0.27.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 +4 -4
- data/.rubocop.yml +26 -5
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -2
- data/lib/mock_redis.rb +1 -1
- data/lib/mock_redis/connection_method.rb +13 -0
- data/lib/mock_redis/database.rb +21 -14
- data/lib/mock_redis/expire_wrapper.rb +1 -1
- data/lib/mock_redis/future.rb +1 -1
- data/lib/mock_redis/geospatial_methods.rb +5 -5
- data/lib/mock_redis/hash_methods.rb +9 -4
- data/lib/mock_redis/info_method.rb +2 -2
- data/lib/mock_redis/multi_db_wrapper.rb +3 -3
- data/lib/mock_redis/pipelined_wrapper.rb +1 -1
- data/lib/mock_redis/stream.rb +22 -2
- data/lib/mock_redis/stream/id.rb +1 -1
- data/lib/mock_redis/stream_methods.rb +16 -1
- data/lib/mock_redis/string_methods.rb +21 -17
- data/lib/mock_redis/transaction_wrapper.rb +3 -3
- data/lib/mock_redis/utility_methods.rb +1 -1
- data/lib/mock_redis/version.rb +1 -1
- data/mock_redis.gemspec +2 -1
- data/spec/commands/blpop_spec.rb +0 -6
- data/spec/commands/brpop_spec.rb +6 -5
- data/spec/commands/connection_spec.rb +15 -0
- data/spec/commands/del_spec.rb +17 -0
- data/spec/commands/exists_spec.rb +34 -5
- data/spec/commands/future_spec.rb +11 -1
- data/spec/commands/geoadd_spec.rb +1 -1
- data/spec/commands/hset_spec.rb +6 -6
- data/spec/commands/keys_spec.rb +17 -0
- data/spec/commands/mget_spec.rb +6 -0
- data/spec/commands/move_spec.rb +5 -5
- data/spec/commands/set_spec.rb +55 -7
- data/spec/commands/setbit_spec.rb +1 -0
- data/spec/commands/srandmember_spec.rb +1 -1
- data/spec/commands/xadd_spec.rb +23 -3
- data/spec/commands/xlen_spec.rb +3 -1
- data/spec/commands/xrange_spec.rb +13 -0
- data/spec/commands/xread_spec.rb +66 -0
- data/spec/commands/xtrim_spec.rb +6 -0
- data/spec/commands/zrange_spec.rb +1 -1
- data/spec/commands/zrangebyscore_spec.rb +1 -1
- data/spec/commands/zrevrange_spec.rb +1 -1
- data/spec/commands/zrevrangebyscore_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/redis_multiplexer.rb +2 -1
- data/spec/transactions_spec.rb +16 -0
- metadata +24 -5
    
        data/spec/commands/set_spec.rb
    CHANGED
    
    | @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe '#set(key, value)' do
         | 
| 4 | 
            +
              let(:key) { 'mock-redis-test' }
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              it "responds with 'OK'" do
         | 
| 5 7 | 
             
                @redises.set('mock-redis-test', 1).should == 'OK'
         | 
| 6 8 | 
             
              end
         | 
| @@ -19,24 +21,72 @@ describe '#set(key, value)' do | |
| 19 21 | 
             
                end
         | 
| 20 22 |  | 
| 21 23 | 
             
                it 'accepts NX' do
         | 
| 22 | 
            -
                  key = 'mock-redis-test'
         | 
| 23 24 | 
             
                  @redises.del(key)
         | 
| 24 25 | 
             
                  @redises.set(key, 1, nx: true).should == true
         | 
| 25 26 | 
             
                  @redises.set(key, 1, nx: true).should == false
         | 
| 26 27 | 
             
                end
         | 
| 27 28 |  | 
| 28 29 | 
             
                it 'accepts XX' do
         | 
| 29 | 
            -
                  key = 'mock-redis-test'
         | 
| 30 30 | 
             
                  @redises.del(key)
         | 
| 31 31 | 
             
                  @redises.set(key, 1, xx: true).should == false
         | 
| 32 32 | 
             
                  @redises.set(key, 1).should == 'OK'
         | 
| 33 33 | 
             
                  @redises.set(key, 1, xx: true).should == true
         | 
| 34 34 | 
             
                end
         | 
| 35 35 |  | 
| 36 | 
            -
                it ' | 
| 37 | 
            -
                  key  | 
| 36 | 
            +
                it 'sets the ttl to -1' do
         | 
| 37 | 
            +
                  @redises.set(key, 1)
         | 
| 38 | 
            +
                  expect(@redises.ttl(key)).to eq(-1)
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                context 'with an expiry time' do
         | 
| 42 | 
            +
                  before :each do
         | 
| 43 | 
            +
                    Timecop.freeze
         | 
| 44 | 
            +
                    @redises.set(key, 1, ex: 90)
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  after :each do
         | 
| 48 | 
            +
                    @redises.del(key)
         | 
| 49 | 
            +
                    Timecop.return
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  it 'has the TTL set' do
         | 
| 53 | 
            +
                    expect(@redises.ttl(key)).to eq 90
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  it 'resets the TTL without keepttl' do
         | 
| 57 | 
            +
                    expect do
         | 
| 58 | 
            +
                      @redises.set(key, 2)
         | 
| 59 | 
            +
                    end.to change { @redises.ttl(key) }.from(90).to(-1)
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  it 'does not change the TTL with keepttl: true' do
         | 
| 63 | 
            +
                    expect do
         | 
| 64 | 
            +
                      @redises.set(key, 2, keepttl: true)
         | 
| 65 | 
            +
                    end.not_to change { @redises.ttl(key) }.from(90)
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                it 'accepts KEEPTTL' do
         | 
| 70 | 
            +
                  expect(@redises.set(key, 1, keepttl: true)).to eq 'OK'
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                it 'does not set TTL without ex' do
         | 
| 74 | 
            +
                  @redises.set(key, 1)
         | 
| 75 | 
            +
                  expect(@redises.ttl(key)).to eq(-1)
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                it 'sets the TTL' do
         | 
| 79 | 
            +
                  Timecop.freeze do
         | 
| 80 | 
            +
                    @redises.set(key, 1, ex: 90)
         | 
| 81 | 
            +
                    expect(@redises.ttl(key)).to eq 90
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                it 'raises on unknown options' do
         | 
| 38 86 | 
             
                  @redises.del(key)
         | 
| 39 | 
            -
                   | 
| 87 | 
            +
                  expect do
         | 
| 88 | 
            +
                    @redises.set(key, 1, logger: :something)
         | 
| 89 | 
            +
                  end.to raise_error(ArgumentError, /unknown keyword/)
         | 
| 40 90 | 
             
                end
         | 
| 41 91 |  | 
| 42 92 | 
             
                context '[mock only]' do
         | 
| @@ -50,7 +100,6 @@ describe '#set(key, value)' do | |
| 50 100 | 
             
                  end
         | 
| 51 101 |  | 
| 52 102 | 
             
                  it 'accepts EX seconds' do
         | 
| 53 | 
            -
                    key = 'mock-redis-test'
         | 
| 54 103 | 
             
                    @mock.set(key, 1, ex: 1).should == 'OK'
         | 
| 55 104 | 
             
                    @mock.get(key).should_not be_nil
         | 
| 56 105 | 
             
                    Time.stub(:now).and_return(@now + 2)
         | 
| @@ -58,7 +107,6 @@ describe '#set(key, value)' do | |
| 58 107 | 
             
                  end
         | 
| 59 108 |  | 
| 60 109 | 
             
                  it 'accepts PX milliseconds' do
         | 
| 61 | 
            -
                    key = 'mock-redis-test'
         | 
| 62 110 | 
             
                    @mock.set(key, 1, px: 500).should == 'OK'
         | 
| 63 111 | 
             
                    @mock.get(key).should_not be_nil
         | 
| 64 112 | 
             
                    Time.stub(:now).and_return(@now + 300 / 1000.to_f)
         | 
| @@ -37,7 +37,7 @@ describe '#srandmember(key)' do | |
| 37 37 | 
             
                  @redises.send_without_checking(:srandmember, @key, 2).size.should == 2
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                it 'returns random members up to count from the set when count is negative even if count.abs is greater than the set size' do # rubocop:disable  | 
| 40 | 
            +
                it 'returns random members up to count from the set when count is negative even if count.abs is greater than the set size' do # rubocop:disable Layout/LineLength
         | 
| 41 41 | 
             
                  @redises.send_without_checking(:srandmember, @key, -5).size.should == 5
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
    
        data/spec/commands/xadd_spec.rb
    CHANGED
    
    | @@ -7,11 +7,14 @@ describe '#xadd("mystream", { f1: "v1", f2: "v2" }, id: "0-0", maxlen: 1000, app | |
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              before :each do
         | 
| 10 | 
            -
                 | 
| 10 | 
            +
                # TODO: Redis appears to be returning a timestamp a few seconds in the future
         | 
| 11 | 
            +
                # so we're ignoring the last 5 digits (time in milliseconds)
         | 
| 12 | 
            +
                @redises._gsub(/\d{5}-\d/, '....-.')
         | 
| 11 13 | 
             
              end
         | 
| 12 14 |  | 
| 13 15 | 
             
              it 'returns an id based on the timestamp' do
         | 
| 14 16 | 
             
                t = Time.now.to_i
         | 
| 17 | 
            +
                id = @redises.xadd(@key, key: 'value')
         | 
| 15 18 | 
             
                expect(@redises.xadd(@key, key: 'value')).to match(/#{t}\d{3}-0/)
         | 
| 16 19 | 
             
              end
         | 
| 17 20 |  | 
| @@ -52,8 +55,7 @@ describe '#xadd("mystream", { f1: "v1", f2: "v2" }, id: "0-0", maxlen: 1000, app | |
| 52 55 | 
             
                expect { @redises.xadd('mock-redis-test:unknown-stream', { key: 'value' }, id: '0') }
         | 
| 53 56 | 
             
                  .to raise_error(
         | 
| 54 57 | 
             
                    Redis::CommandError,
         | 
| 55 | 
            -
                    'ERR The ID specified in XADD  | 
| 56 | 
            -
                    'stream top item'
         | 
| 58 | 
            +
                    'ERR The ID specified in XADD must be greater than 0-0'
         | 
| 57 59 | 
             
                  )
         | 
| 58 60 | 
             
              end
         | 
| 59 61 |  | 
| @@ -99,4 +101,22 @@ describe '#xadd("mystream", { f1: "v1", f2: "v2" }, id: "0-0", maxlen: 1000, app | |
| 99 101 | 
             
                  ]
         | 
| 100 102 | 
             
                )
         | 
| 101 103 | 
             
              end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
              it 'supports a maxlen greater than the current size' do
         | 
| 106 | 
            +
                @redises.xadd(@key, { key1: 'value1' }, id: '1234567891234-0')
         | 
| 107 | 
            +
                @redises.xadd(@key, { key2: 'value2' }, id: '1234567891245-0', maxlen: 1000)
         | 
| 108 | 
            +
                expect(@redises.xrange(@key, '-', '+')).to eq(
         | 
| 109 | 
            +
                  [
         | 
| 110 | 
            +
                    ['1234567891234-0', { 'key1' => 'value1' }],
         | 
| 111 | 
            +
                    ['1234567891245-0', { 'key2' => 'value2' }],
         | 
| 112 | 
            +
                  ]
         | 
| 113 | 
            +
                )
         | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
              it 'creates an empty stream with maxlen of 0' do
         | 
| 117 | 
            +
                @redises.xadd(@key, { key: 'value' }, maxlen: 0)
         | 
| 118 | 
            +
                expect(@redises.xlen(@key)).to eq 0
         | 
| 119 | 
            +
                expect(@redises.xrange(@key, '-', '+')).to eq([])
         | 
| 120 | 
            +
                expect(@redises.exists?(@key)).to eq true
         | 
| 121 | 
            +
              end
         | 
| 102 122 | 
             
            end
         | 
    
        data/spec/commands/xlen_spec.rb
    CHANGED
    
    | @@ -7,7 +7,9 @@ describe '#xlen(key)' do | |
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 9 | 
             
              before :each do
         | 
| 10 | 
            -
                 | 
| 10 | 
            +
                # TODO: Redis appears to be returning a timestamp a few seconds in the future
         | 
| 11 | 
            +
                # so we're ignoring the last 5 digits (time in milliseconds)
         | 
| 12 | 
            +
                @redises._gsub(/\d{5}-\d/, '...-.')
         | 
| 11 13 | 
             
              end
         | 
| 12 14 |  | 
| 13 15 | 
             
              it 'returns the number of items in the stream' do
         | 
| @@ -54,6 +54,19 @@ describe '#xrange("mystream", first: "0-1", last: "0-3", count: 10)' do | |
| 54 54 | 
             
                  )
         | 
| 55 55 | 
             
                end
         | 
| 56 56 |  | 
| 57 | 
            +
                it 'returns all entries with a lower limit of 0-0' do
         | 
| 58 | 
            +
                  expect(@redises.xrange(@key, '0-0', '+')).to eq(
         | 
| 59 | 
            +
                    [
         | 
| 60 | 
            +
                      ['1234567891234-0', { 'key1' => 'value1' }],
         | 
| 61 | 
            +
                      ['1234567891245-0', { 'key2' => 'value2' }],
         | 
| 62 | 
            +
                      ['1234567891245-1', { 'key3' => 'value3' }],
         | 
| 63 | 
            +
                      ['1234567891278-0', { 'key4' => 'value4' }],
         | 
| 64 | 
            +
                      ['1234567891278-1', { 'key5' => 'value5' }],
         | 
| 65 | 
            +
                      ['1234567891299-0', { 'key6' => 'value6' }]
         | 
| 66 | 
            +
                    ]
         | 
| 67 | 
            +
                  )
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 57 70 | 
             
                it 'returns entries with an upper limit' do
         | 
| 58 71 | 
             
                  expect(@redises.xrange(@key, '-', '1234567891285-0')).to eq(
         | 
| 59 72 | 
             
                    [
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe '#xread(keys, ids)' do
         | 
| 4 | 
            +
              before :all do
         | 
| 5 | 
            +
                sleep 1 - (Time.now.to_f % 1)
         | 
| 6 | 
            +
                @key = 'mock-redis-test:xread'
         | 
| 7 | 
            +
                @key1 = 'mock-redis-test:xread1'
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'reads a single entry' do
         | 
| 11 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-0')
         | 
| 12 | 
            +
                expect(@redises.xread(@key, '0-0'))
         | 
| 13 | 
            +
                  .to eq({ @key => [['1234567891234-0', { 'key' => 'value' }]] })
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              it 'reads multiple entries from the beginning of the stream' do
         | 
| 17 | 
            +
                @redises.xadd(@key, { key0: 'value0' }, id: '1234567891234-0')
         | 
| 18 | 
            +
                @redises.xadd(@key, { key1: 'value1' }, id: '1234567891234-1')
         | 
| 19 | 
            +
                expect(@redises.xread(@key, '0-0'))
         | 
| 20 | 
            +
                  .to eq({ @key => [['1234567891234-0', { 'key0' => 'value0' }],
         | 
| 21 | 
            +
                                    ['1234567891234-1', { 'key1' => 'value1' }]] })
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              it 'reads entries greater than the ID passed' do
         | 
| 25 | 
            +
                @redises.xadd(@key, { key0: 'value0' }, id: '1234567891234-0')
         | 
| 26 | 
            +
                @redises.xadd(@key, { key1: 'value1' }, id: '1234567891234-1')
         | 
| 27 | 
            +
                expect(@redises.xread(@key, '1234567891234-0'))
         | 
| 28 | 
            +
                  .to eq({ @key => [['1234567891234-1', { 'key1' => 'value1' }]] })
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it 'reads from multiple streams' do
         | 
| 32 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-0')
         | 
| 33 | 
            +
                @redises.xadd(@key1, { key1: 'value1' }, id: '1234567891234-0')
         | 
| 34 | 
            +
                expect(@redises.xread([@key, @key1], %w[0-0 0-0]))
         | 
| 35 | 
            +
                  .to eq({ @key => [['1234567891234-0', { 'key' => 'value' }]],
         | 
| 36 | 
            +
                           @key1 => [['1234567891234-0', { 'key1' => 'value1' }]] })
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              it 'reads from multiple streams at the given IDs' do
         | 
| 40 | 
            +
                @redises.xadd(@key, { key: 'value0' }, id: '1234567891234-0')
         | 
| 41 | 
            +
                @redises.xadd(@key, { key: 'value1' }, id: '1234567891234-1')
         | 
| 42 | 
            +
                @redises.xadd(@key, { key: 'value2' }, id: '1234567891234-2')
         | 
| 43 | 
            +
                @redises.xadd(@key1, { key1: 'value0' }, id: '1234567891234-0')
         | 
| 44 | 
            +
                @redises.xadd(@key1, { key1: 'value1' }, id: '1234567891234-1')
         | 
| 45 | 
            +
                @redises.xadd(@key1, { key1: 'value2' }, id: '1234567891234-2')
         | 
| 46 | 
            +
                # The first stream won't return anything since we specify the last ID
         | 
| 47 | 
            +
                expect(@redises.xread([@key, @key1], %w[1234567891234-2 1234567891234-1]))
         | 
| 48 | 
            +
                  .to eq({ @key1 => [['1234567891234-2', { 'key1' => 'value2' }]] })
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              it 'supports the block parameter' do
         | 
| 52 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-0')
         | 
| 53 | 
            +
                expect(@redises.xread(@key, '0-0', block: 1000))
         | 
| 54 | 
            +
                  .to eq({ @key => [['1234567891234-0', { 'key' => 'value' }]] })
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              it 'limits results with count' do
         | 
| 58 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-0')
         | 
| 59 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-1')
         | 
| 60 | 
            +
                @redises.xadd(@key, { key: 'value' }, id: '1234567891234-2')
         | 
| 61 | 
            +
                expect(@redises.xread(@key, '0-0', count: 1))
         | 
| 62 | 
            +
                  .to eq({ @key => [['1234567891234-0', { 'key' => 'value' }]] })
         | 
| 63 | 
            +
                expect(@redises.xread(@key, '1234567891234-0', count: 1))
         | 
| 64 | 
            +
                  .to eq({ @key => [['1234567891234-1', { 'key' => 'value' }]] })
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
            end
         | 
    
        data/spec/commands/xtrim_spec.rb
    CHANGED
    
    | @@ -16,6 +16,12 @@ describe '#xtrim("mystream", 1000, approximate: true)' do | |
| 16 16 | 
             
                expect(@redises.xtrim(@key, 4)).to eq 2
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 | 
            +
              it 'returns 0 if count is greater than size' do
         | 
| 20 | 
            +
                initial = @redises.xrange(@key, '-', '+')
         | 
| 21 | 
            +
                expect(@redises.xtrim(@key, 1000)).to eq 0
         | 
| 22 | 
            +
                expect(@redises.xrange(@key, '-', '+')).to eql(initial)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 19 25 | 
             
              it 'deletes the oldes elements' do
         | 
| 20 26 | 
             
                @redises.xtrim(@key, 4)
         | 
| 21 27 | 
             
                expect(@redises.xrange(@key, '-', '+')).to eq(
         | 
| @@ -15,7 +15,7 @@ describe '#zrangebyscore(key, start, stop [:with_scores => true] [:limit => [off | |
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                it 'should return an empty array' do
         | 
| 18 | 
            -
                  @redises.exists(@key).should == false
         | 
| 18 | 
            +
                  @redises.exists?(@key).should == false
         | 
| 19 19 | 
             
                  @redises.zrangebyscore(@key, 0, 4).should == []
         | 
| 20 20 | 
             
                end
         | 
| 21 21 | 
             
              end
         | 
| @@ -15,7 +15,7 @@ describe '#zrevrange(key, start, stop [, :with_scores => true])' do | |
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                it 'should return an empty array' do
         | 
| 18 | 
            -
                  @redises.exists(@key).should == false
         | 
| 18 | 
            +
                  @redises.exists?(@key).should == false
         | 
| 19 19 | 
             
                  @redises.zrevrange(@key, 0, 4).should == []
         | 
| 20 20 | 
             
                end
         | 
| 21 21 | 
             
              end
         | 
| @@ -15,7 +15,7 @@ describe '#zrevrangebyscore(key, start, stop [:with_scores => true] [:limit => [ | |
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                it 'should return an empty array' do
         | 
| 18 | 
            -
                  @redises.exists(@key).should == false
         | 
| 18 | 
            +
                  @redises.exists?(@key).should == false
         | 
| 19 19 | 
             
                  @redises.zrevrangebyscore(@key, 0, 4).should == []
         | 
| 20 20 | 
             
                end
         | 
| 21 21 | 
             
              end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -11,11 +11,12 @@ end | |
| 11 11 | 
             
            require 'rspec/its'
         | 
| 12 12 | 
             
            require 'redis'
         | 
| 13 13 | 
             
            $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, '..', '..', 'lib')))
         | 
| 14 | 
            +
            require 'ruby2_keywords'
         | 
| 14 15 | 
             
            require 'mock_redis'
         | 
| 15 16 | 
             
            require 'timecop'
         | 
| 16 17 |  | 
| 17 18 | 
             
            $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..')))
         | 
| 18 | 
            -
            Dir['spec/support/**/*.rb'].each { |x| require x }
         | 
| 19 | 
            +
            Dir['spec/support/**/*.rb'].sort.each { |x| require x }
         | 
| 19 20 |  | 
| 20 21 | 
             
            module TypeCheckingHelper
         | 
| 21 22 | 
             
              def method_from_description(example)
         | 
| @@ -9,6 +9,7 @@ class RedisMultiplexer < BlankSlate | |
| 9 9 |  | 
| 10 10 | 
             
              def initialize(*a)
         | 
| 11 11 | 
             
                @mock_redis = MockRedis.new(*a)
         | 
| 12 | 
            +
                Redis.exists_returns_integer = true
         | 
| 12 13 | 
             
                @real_redis = Redis.new(*a)
         | 
| 13 14 | 
             
                _gsub_clear
         | 
| 14 15 | 
             
              end
         | 
| @@ -22,7 +23,7 @@ class RedisMultiplexer < BlankSlate | |
| 22 23 | 
             
                @gsub_from = @gsub_to = ''
         | 
| 23 24 | 
             
              end
         | 
| 24 25 |  | 
| 25 | 
            -
              def method_missing(method, *args, &blk)
         | 
| 26 | 
            +
              ruby2_keywords def method_missing(method, *args, &blk)
         | 
| 26 27 | 
             
                # If we're in a Redis command that accepts a block, and we execute more
         | 
| 27 28 | 
             
                # redis commands, ONLY execute them on the Redis implementation that the
         | 
| 28 29 | 
             
                # block came from.
         | 
    
        data/spec/transactions_spec.rb
    CHANGED
    
    | @@ -67,6 +67,22 @@ describe 'transactions (multi/exec/discard)' do | |
| 67 67 | 
             
                  @redises.get('counter').should eq '6'
         | 
| 68 68 | 
             
                  @redises.get('test').should eq '1'
         | 
| 69 69 | 
             
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                it 'allows blocks within multi blocks' do
         | 
| 72 | 
            +
                  @redises.set('foo', 'bar')
         | 
| 73 | 
            +
                  @redises.set('fuu', 'baz')
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  result = nil
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  @redises.multi do |r|
         | 
| 78 | 
            +
                    result = r.mget('foo', 'fuu') { |reply| reply.map(&:upcase) }
         | 
| 79 | 
            +
                    r.del('foo', 'fuu')
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  result.value.should eq %w[BAR BAZ]
         | 
| 83 | 
            +
                  @redises.get('foo').should eq nil
         | 
| 84 | 
            +
                  @redises.get('fuu').should eq nil
         | 
| 85 | 
            +
                end
         | 
| 70 86 | 
             
              end
         | 
| 71 87 |  | 
| 72 88 | 
             
              context '#discard' do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mock_redis
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.27.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shane da Silva
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2021-01-07 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: redis
         | 
| @@ -17,14 +17,14 @@ dependencies: | |
| 17 17 | 
             
                requirements:
         | 
| 18 18 | 
             
                - - "~>"
         | 
| 19 19 | 
             
                  - !ruby/object:Gem::Version
         | 
| 20 | 
            -
                    version: 4. | 
| 20 | 
            +
                    version: 4.2.0
         | 
| 21 21 | 
             
              type: :development
         | 
| 22 22 | 
             
              prerelease: false
         | 
| 23 23 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 24 | 
             
                requirements:
         | 
| 25 25 | 
             
                - - "~>"
         | 
| 26 26 | 
             
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            -
                    version: 4. | 
| 27 | 
            +
                    version: 4.2.0
         | 
| 28 28 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 29 29 | 
             
              name: rspec
         | 
| 30 30 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -53,6 +53,20 @@ dependencies: | |
| 53 53 | 
             
                - - "~>"
         | 
| 54 54 | 
             
                  - !ruby/object:Gem::Version
         | 
| 55 55 | 
             
                    version: '1.0'
         | 
| 56 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 57 | 
            +
              name: ruby2_keywords
         | 
| 58 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - ">="
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '0'
         | 
| 63 | 
            +
              type: :development
         | 
| 64 | 
            +
              prerelease: false
         | 
| 65 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ">="
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '0'
         | 
| 56 70 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 57 71 | 
             
              name: timecop
         | 
| 58 72 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -90,6 +104,7 @@ files: | |
| 90 104 | 
             
            - Rakefile
         | 
| 91 105 | 
             
            - lib/mock_redis.rb
         | 
| 92 106 | 
             
            - lib/mock_redis/assertions.rb
         | 
| 107 | 
            +
            - lib/mock_redis/connection_method.rb
         | 
| 93 108 | 
             
            - lib/mock_redis/database.rb
         | 
| 94 109 | 
             
            - lib/mock_redis/exceptions.rb
         | 
| 95 110 | 
             
            - lib/mock_redis/expire_wrapper.rb
         | 
| @@ -126,6 +141,7 @@ files: | |
| 126 141 | 
             
            - spec/commands/brpop_spec.rb
         | 
| 127 142 | 
             
            - spec/commands/brpoplpush_spec.rb
         | 
| 128 143 | 
             
            - spec/commands/connected_spec.rb
         | 
| 144 | 
            +
            - spec/commands/connection_spec.rb
         | 
| 129 145 | 
             
            - spec/commands/dbsize_spec.rb
         | 
| 130 146 | 
             
            - spec/commands/decr_spec.rb
         | 
| 131 147 | 
             
            - spec/commands/decrby_spec.rb
         | 
| @@ -241,6 +257,7 @@ files: | |
| 241 257 | 
             
            - spec/commands/xadd_spec.rb
         | 
| 242 258 | 
             
            - spec/commands/xlen_spec.rb
         | 
| 243 259 | 
             
            - spec/commands/xrange_spec.rb
         | 
| 260 | 
            +
            - spec/commands/xread_spec.rb
         | 
| 244 261 | 
             
            - spec/commands/xrevrange_spec.rb
         | 
| 245 262 | 
             
            - spec/commands/xtrim_spec.rb
         | 
| 246 263 | 
             
            - spec/commands/zadd_spec.rb
         | 
| @@ -293,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 293 310 | 
             
                - !ruby/object:Gem::Version
         | 
| 294 311 | 
             
                  version: '0'
         | 
| 295 312 | 
             
            requirements: []
         | 
| 296 | 
            -
            rubygems_version: 3.1. | 
| 313 | 
            +
            rubygems_version: 3.1.4
         | 
| 297 314 | 
             
            signing_key: 
         | 
| 298 315 | 
             
            specification_version: 4
         | 
| 299 316 | 
             
            summary: Redis mock that just lives in memory; useful for testing.
         | 
| @@ -310,6 +327,7 @@ test_files: | |
| 310 327 | 
             
            - spec/commands/brpop_spec.rb
         | 
| 311 328 | 
             
            - spec/commands/brpoplpush_spec.rb
         | 
| 312 329 | 
             
            - spec/commands/connected_spec.rb
         | 
| 330 | 
            +
            - spec/commands/connection_spec.rb
         | 
| 313 331 | 
             
            - spec/commands/dbsize_spec.rb
         | 
| 314 332 | 
             
            - spec/commands/decr_spec.rb
         | 
| 315 333 | 
             
            - spec/commands/decrby_spec.rb
         | 
| @@ -425,6 +443,7 @@ test_files: | |
| 425 443 | 
             
            - spec/commands/xadd_spec.rb
         | 
| 426 444 | 
             
            - spec/commands/xlen_spec.rb
         | 
| 427 445 | 
             
            - spec/commands/xrange_spec.rb
         | 
| 446 | 
            +
            - spec/commands/xread_spec.rb
         | 
| 428 447 | 
             
            - spec/commands/xrevrange_spec.rb
         | 
| 429 448 | 
             
            - spec/commands/xtrim_spec.rb
         | 
| 430 449 | 
             
            - spec/commands/zadd_spec.rb
         |