Sha256: 8c938fb61142db828c93d416d451765870a01874c84b95c8fcd97d9898b932b7

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

require 'spec_helper'
require 'riak'

describe Riak::Counter, test_client: true, integration: true do
  before :all do
    @bucket = random_bucket 'counter_spec'
    @bucket.allow_mult = true

    @counter = Riak::Counter.new @bucket, 'counter_spec'
  end

  it 'should read and update' do
    initial = @counter.value

    @counter.increment
    @counter.increment

    expect(@counter.value).to eq(initial + 2)

    @counter.decrement 2

    expect(@counter.value).to eq(initial)

    5.times do
      amt = rand(10_000)
      
      @counter.increment amt
      expect(@counter.value).to eq(initial + amt)

      @counter.decrement (amt * 2)
      expect(@counter.value).to eq(initial - amt)

      expect(@counter.increment_and_return(amt)).to eq(initial)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.0.0 spec/integration/riak/counters_spec.rb
riak-client-2.0.0.rc2 spec/integration/riak/counters_spec.rb
riak-client-2.0.0.rc1 spec/integration/riak/counters_spec.rb