Sha256: 76f5924f7471ae8f9b961b3dad826a61fa10460ae5dd6c47f062c37db56c9ad0

Contents?: true

Size: 1.01 KB

Versions: 52

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe WebMock::Util::HashCounter do

  it "should return 0 for non existing key" do
    WebMock::Util::HashCounter.new.get(:abc).should == 0
  end

  it "should increase the returned value on every put with the same key" do
    counter = WebMock::Util::HashCounter.new
    counter.put(:abc)
    counter.get(:abc).should == 1
    counter.put(:abc)
    counter.get(:abc).should == 2
  end

  it "should only increase value for given key provided to put" do
    counter = WebMock::Util::HashCounter.new
    counter.put(:abc)
    counter.get(:abc).should == 1
    counter.get(:def).should == 0
  end

  describe "each" do
    it "should provide elements in order of the last modified" do
      counter = WebMock::Util::HashCounter.new
      counter.put(:a)
      counter.put(:b)
      counter.put(:c)
      counter.put(:b)
      counter.put(:a)
      counter.put(:d)

      elements = []
      counter.each {|k,v| elements << [k,v]}
      elements.should == [[:c, 1], [:b, 2], [:a, 2], [:d, 1]]
    end
  end
end

Version data entries

52 entries across 52 versions & 4 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/spec/unit/util/hash_counter_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/spec/unit/util/hash_counter_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/spec/unit/util/hash_counter_spec.rb
webmock-1.20.3 spec/unit/util/hash_counter_spec.rb
webmock-1.20.2 spec/unit/util/hash_counter_spec.rb
webmock-1.20.1 spec/unit/util/hash_counter_spec.rb
webmock-1.20.0 spec/unit/util/hash_counter_spec.rb
webmock-1.19.0 spec/unit/util/hash_counter_spec.rb
whos_dated_who-0.1.0 vendor/bundle/gems/webmock-1.18.0/spec/unit/util/hash_counter_spec.rb
whos_dated_who-0.0.1 vendor/bundle/gems/webmock-1.18.0/spec/unit/util/hash_counter_spec.rb
webmock-1.18.0 spec/unit/util/hash_counter_spec.rb
webmock-1.17.4 spec/unit/util/hash_counter_spec.rb
webmock-1.17.3 spec/unit/util/hash_counter_spec.rb
webmock-1.17.2 spec/unit/util/hash_counter_spec.rb
webmock-1.17.1 spec/unit/util/hash_counter_spec.rb
webmock-1.17.0 spec/unit/util/hash_counter_spec.rb
webmock-1.16.1 spec/unit/util/hash_counter_spec.rb
webmock-1.16.0 spec/unit/util/hash_counter_spec.rb
webmock-1.15.2 spec/unit/util/hash_counter_spec.rb
webmock-1.15.0 spec/unit/util/hash_counter_spec.rb