Sha256: 62e0536337ec48d2ef9c92a65f0a71eb9395d80c375a8bfd884bcfd944dc0a94

Contents?: true

Size: 767 Bytes

Versions: 11

Compression:

Stored size: 767 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 'reads and updates' 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

11 entries across 11 versions & 2 rubygems

Version Path
riak-client-2.5.0 spec/integration/riak/counters_spec.rb
riak-client-2.4.1 spec/integration/riak/counters_spec.rb
riak-client-2.4.0 spec/integration/riak/counters_spec.rb
riak-client-2.4.0.pre1 spec/integration/riak/counters_spec.rb
riak-client-2.3.2 spec/integration/riak/counters_spec.rb
riak-client-2.3.1 spec/integration/riak/counters_spec.rb
riak-client-2.3.0 spec/integration/riak/counters_spec.rb
riak-client-2.2.2 spec/integration/riak/counters_spec.rb
riak-client-2.2.1 spec/integration/riak/counters_spec.rb
riak-client-noenc-1.0.0 spec/integration/riak/counters_spec.rb
riak-client-2.2.0 spec/integration/riak/counters_spec.rb