Sha256: 0b43362d02d24abf1d8ad4a7226ad5b41cf46a7ad330b9ba2156d0120cbf2f5c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "HashPersistent::Counter" do
  context "when mixed-in to a class" do
    before(:each) do
      class CounterFoo
        include HashPersistent::Counter
      end
    end

    it "should impart a next_key class method" do
      CounterFoo.respond_to?(:next_key).should be_true
    end

    it "should supply a new key on each next_key call" do
      CounterFoo.next_key.should_not == CounterFoo.next_key
    end
    
    it "should be careful when incrementing the key in multi-threaded/process environment" do
      pending
    end
  end
  
  context "when mixed-in to more than one class" do
    before(:each) do
      class CounterFred
        include HashPersistent::Counter
      end
      class CounterBarney
        include HashPersistent::Counter
      end
    end
    
    it "should count independently for each class" do
      CounterFred.next_key.should == CounterBarney.next_key
      CounterFred.next_key.should == CounterBarney.next_key
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kissifer-hash-persistent-0.1.1 spec/counter_spec.rb