Sha256: f174478d36cbf66a48e06376748cbdead7992bf904704bafb01790afa83d5d3b

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../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

11 entries across 11 versions & 2 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/webmock-1.6.4/spec/util/hash_counter_spec.rb
webmock-1.7.5 spec/util/hash_counter_spec.rb
webmock-1.7.4 spec/util/hash_counter_spec.rb
webmock-1.7.3 spec/util/hash_counter_spec.rb
webmock-1.7.2 spec/util/hash_counter_spec.rb
webmock-1.7.1 spec/util/hash_counter_spec.rb
webmock-1.7.0 spec/util/hash_counter_spec.rb
webmock-1.6.4 spec/util/hash_counter_spec.rb
webmock-1.6.2 spec/util/hash_counter_spec.rb
webmock-1.6.1 spec/util/hash_counter_spec.rb
webmock-1.6.0 spec/util/hash_counter_spec.rb