spec/monetaspecs.rb in moneta-0.7.17 vs spec/monetaspecs.rb in moneta-0.7.18
- old
+ new
@@ -249,10 +249,22 @@
store[0].should == 0
store[0] = nil
store[0].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = 0
+ store[0].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[nil] = 0
store[nil].should == 0
store.load(nil).should == 0
end
@@ -289,10 +301,22 @@
store[nil].should == 0
store[nil] = nil
store[nil].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = 0
+ store[nil].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[0] = nil
store[0].should == nil
store.load(0).should == nil
end
@@ -329,10 +353,22 @@
store[0].should == nil
store[0] = 0
store[0].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = nil
+ store[0].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store[nil] = nil
store[nil].should == nil
store.load(nil).should == nil
end
@@ -368,10 +404,22 @@
store[nil] = nil
store[nil].should == nil
store[nil] = 0
store[nil].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = nil
+ store[nil].should == nil
+ end
end
#################### persist_nilkey_nilvalue ####################
shared_examples_for 'persist_nilkey_nilvalue' do
@@ -652,10 +700,22 @@
store[0] = 41
store[0].should == 41
store[0] = -12
store[0].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = 41
+ store[0].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = 41
store.fetch(0, -12).should == 41
end
@@ -703,10 +763,22 @@
store[nil] = 41
store[nil].should == 41
store[nil] = -12
store[nil].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = 41
+ store[nil].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = 41
store.fetch(nil, -12).should == 41
end
@@ -754,10 +826,22 @@
store[0] = -12
store[0].should == -12
store[0] = 41
store[0].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = -12
+ store[0].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = -12
store.fetch(0, 41).should == -12
end
@@ -805,10 +889,22 @@
store[nil] = -12
store[nil].should == -12
store[nil] = 41
store[nil].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = -12
+ store[nil].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = -12
store.fetch(nil, 41).should == -12
end
@@ -850,10 +946,990 @@
@store = nil
store[nil].should == -12
end
end
+#################### null_nilkey_numbervalue ####################
+
+shared_examples_for 'null_nilkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[0].should be_nil
+ store.load(0).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[0] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0] = 123.456
+ store[nil] = -98.7
+ store.clear.should equal(store)
+ store.key?(0).should be_false
+ store.key?(nil).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0, options).should be_false
+ store.load(0, options).should be_nil
+ store.fetch(0, 42, options).should == 42
+ store.fetch(0, options) { 42 }.should == 42
+ store.delete(0, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[nil].should be_nil
+ store.load(nil).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[nil] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(nil).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(nil).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[nil] = 123.456
+ store[0] = -98.7
+ store.clear.should equal(store)
+ store.key?(nil).should be_false
+ store.key?(0).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(nil, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = nil
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(nil, options).should be_false
+ store.load(nil, options).should be_nil
+ store.fetch(nil, 42, options).should == 42
+ store.fetch(nil, options) { 42 }.should == 42
+ store.delete(nil, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(nil, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0].should be_nil
+ store.load(0).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[0] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0] = -98.7
+ store[nil] = 123.456
+ store.clear.should equal(store)
+ store.key?(0).should be_false
+ store.key?(nil).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0, options).should be_false
+ store.load(0, options).should be_nil
+ store.fetch(0, 42, options).should == 42
+ store.fetch(0, options) { 42 }.should == 42
+ store.delete(0, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[nil].should be_nil
+ store.load(nil).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[nil] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(nil).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(nil).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[nil] = -98.7
+ store[0] = 123.456
+ store.clear.should equal(store)
+ store.key?(nil).should be_false
+ store.key?(0).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(nil, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = nil
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(nil, options).should be_false
+ store.load(nil, options).should be_nil
+ store.fetch(nil, 42, options).should == 42
+ store.fetch(nil, options) { 42 }.should == 42
+ store.delete(nil, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(nil, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0].should be_nil
+ store.load(0).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[0] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0] = 340282366920938463463374607431768211456
+ store[nil] = 33
+ store.clear.should equal(store)
+ store.key?(0).should be_false
+ store.key?(nil).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0, options).should be_false
+ store.load(0, options).should be_nil
+ store.fetch(0, 42, options).should == 42
+ store.fetch(0, options) { 42 }.should == 42
+ store.delete(0, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[nil].should be_nil
+ store.load(nil).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[nil] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(nil).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(nil).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[nil] = 340282366920938463463374607431768211456
+ store[0] = 33
+ store.clear.should equal(store)
+ store.key?(nil).should be_false
+ store.key?(0).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(nil, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = nil
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(nil, options).should be_false
+ store.load(nil, options).should be_nil
+ store.fetch(nil, 42, options).should == 42
+ store.fetch(nil, options) { 42 }.should == 42
+ store.delete(nil, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(nil, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0].should be_nil
+ store.load(0).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[0] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0] = 33
+ store[nil] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(0).should be_false
+ store.key?(nil).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0, options).should be_false
+ store.load(0, options).should be_nil
+ store.fetch(0, 42, options).should == 42
+ store.fetch(0, options) { 42 }.should == 42
+ store.delete(0, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[nil].should be_nil
+ store.load(nil).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[nil] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(nil).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(nil).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[nil] = 33
+ store[0] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(nil).should be_false
+ store.key?(0).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(nil, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = nil
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(nil, options).should be_false
+ store.load(nil, options).should be_nil
+ store.fetch(nil, 42, options).should == 42
+ store.fetch(nil, options) { 42 }.should == 42
+ store.delete(nil, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(nil, 33, options).should == 33
+ end
+end
+
+#################### store_nilkey_numbervalue ####################
+
+shared_examples_for 'store_nilkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0] = 123.456
+ store[0].should == 123.456
+ store.load(0).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0] = 123.456
+ store.key?(0).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(0, value).should equal(value)
+ store[0].should == 123.456
+ store.load(0).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[0] = 123.456
+ store[nil] = -98.7
+ store.clear.should equal(store)
+ store[0] = 123.456
+ store[0].should == 123.456
+ store[nil].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0] = 123.456
+ store.delete(0).should == 123.456
+ store.key?(0).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0] = 123.456
+ store[0].should == 123.456
+ store[0] = -98.7
+ store[0].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = 123.456
+ store[0].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0] = 123.456
+ store.fetch(0, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(0) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[nil] = 123.456
+ store[nil].should == 123.456
+ store.load(nil).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[nil] = 123.456
+ store.key?(nil).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(nil, value).should equal(value)
+ store[nil].should == 123.456
+ store.load(nil).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[nil] = 123.456
+ store[0] = -98.7
+ store.clear.should equal(store)
+ store[nil] = 123.456
+ store[nil].should == 123.456
+ store[0].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[nil] = 123.456
+ store.delete(nil).should == 123.456
+ store.key?(nil).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[nil] = 123.456
+ store[nil].should == 123.456
+ store[nil] = -98.7
+ store[nil].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = 123.456
+ store[nil].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[nil] = 123.456
+ store.fetch(nil, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[nil] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(nil) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0] = -98.7
+ store[0].should == -98.7
+ store.load(0).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0] = -98.7
+ store.key?(0).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(0, value).should equal(value)
+ store[0].should == -98.7
+ store.load(0).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[0] = -98.7
+ store[nil] = 123.456
+ store.clear.should equal(store)
+ store[0] = -98.7
+ store[0].should == -98.7
+ store[nil].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0] = -98.7
+ store.delete(0).should == -98.7
+ store.key?(0).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0] = -98.7
+ store[0].should == -98.7
+ store[0] = 123.456
+ store[0].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = -98.7
+ store[0].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0] = -98.7
+ store.fetch(0, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(0) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[nil] = -98.7
+ store[nil].should == -98.7
+ store.load(nil).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[nil] = -98.7
+ store.key?(nil).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(nil, value).should equal(value)
+ store[nil].should == -98.7
+ store.load(nil).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[nil] = -98.7
+ store[0] = 123.456
+ store.clear.should equal(store)
+ store[nil] = -98.7
+ store[nil].should == -98.7
+ store[0].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[nil] = -98.7
+ store.delete(nil).should == -98.7
+ store.key?(nil).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[nil] = -98.7
+ store[nil].should == -98.7
+ store[nil] = 123.456
+ store[nil].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = -98.7
+ store[nil].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[nil] = -98.7
+ store.fetch(nil, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[nil] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(nil) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0] = 340282366920938463463374607431768211456
+ store[0].should == 340282366920938463463374607431768211456
+ store.load(0).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0] = 340282366920938463463374607431768211456
+ store.key?(0).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(0, value).should equal(value)
+ store[0].should == 340282366920938463463374607431768211456
+ store.load(0).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[0] = 340282366920938463463374607431768211456
+ store[nil] = 33
+ store.clear.should equal(store)
+ store[0] = 340282366920938463463374607431768211456
+ store[0].should == 340282366920938463463374607431768211456
+ store[nil].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0] = 340282366920938463463374607431768211456
+ store.delete(0).should == 340282366920938463463374607431768211456
+ store.key?(0).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0] = 340282366920938463463374607431768211456
+ store[0].should == 340282366920938463463374607431768211456
+ store[0] = 33
+ store[0].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[0].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0] = 340282366920938463463374607431768211456
+ store.fetch(0, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(0) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[nil] = 340282366920938463463374607431768211456
+ store[nil].should == 340282366920938463463374607431768211456
+ store.load(nil).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[nil] = 340282366920938463463374607431768211456
+ store.key?(nil).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(nil, value).should equal(value)
+ store[nil].should == 340282366920938463463374607431768211456
+ store.load(nil).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[nil] = 340282366920938463463374607431768211456
+ store[0] = 33
+ store.clear.should equal(store)
+ store[nil] = 340282366920938463463374607431768211456
+ store[nil].should == 340282366920938463463374607431768211456
+ store[0].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[nil] = 340282366920938463463374607431768211456
+ store.delete(nil).should == 340282366920938463463374607431768211456
+ store.key?(nil).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[nil] = 340282366920938463463374607431768211456
+ store[nil].should == 340282366920938463463374607431768211456
+ store[nil] = 33
+ store[nil].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[nil].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[nil] = 340282366920938463463374607431768211456
+ store.fetch(nil, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[nil] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(nil) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0] = 33
+ store[0].should == 33
+ store.load(0).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0] = 33
+ store.key?(0).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(0, value).should equal(value)
+ store[0].should == 33
+ store.load(0).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[0] = 33
+ store[nil] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[0] = 33
+ store[0].should == 33
+ store[nil].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0] = 33
+ store.delete(0).should == 33
+ store.key?(0).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0] = 33
+ store[0].should == 33
+ store[0] = 340282366920938463463374607431768211456
+ store[0].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = 33
+ store[0].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0] = 33
+ store.fetch(0, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0] = 33
+ unaltered = 'unaltered'
+ store.fetch(0) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[nil] = 33
+ store[nil].should == 33
+ store.load(nil).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[nil] = 33
+ store.key?(nil).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(nil, value).should equal(value)
+ store[nil].should == 33
+ store.load(nil).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[nil] = 33
+ store[0] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[nil] = 33
+ store[nil].should == 33
+ store[0].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[nil] = 33
+ store.delete(nil).should == 33
+ store.key?(nil).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[nil] = 33
+ store[nil].should == 33
+ store[nil] = 340282366920938463463374607431768211456
+ store[nil].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = 33
+ store[nil].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[nil] = 33
+ store.fetch(nil, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[nil] = 33
+ unaltered = 'unaltered'
+ store.fetch(nil) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_nilkey_numbervalue ####################
+
+shared_examples_for 'persist_nilkey_numbervalue' do
+ it 'persists values' do
+ store[0] = 123.456
+ store.close
+ @store = nil
+ store[0].should == 123.456
+ end
+
+ it 'persists values' do
+ store[nil] = 123.456
+ store.close
+ @store = nil
+ store[nil].should == 123.456
+ end
+
+ it 'persists values' do
+ store[0] = -98.7
+ store.close
+ @store = nil
+ store[0].should == -98.7
+ end
+
+ it 'persists values' do
+ store[nil] = -98.7
+ store.close
+ @store = nil
+ store[nil].should == -98.7
+ end
+
+ it 'persists values' do
+ store[0] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[0].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[nil] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[nil].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[0] = 33
+ store.close
+ @store = nil
+ store[0].should == 33
+ end
+
+ it 'persists values' do
+ store[nil] = 33
+ store.close
+ @store = nil
+ store[nil].should == 33
+ end
+end
+
#################### null_nilkey_booleanvalue ####################
shared_examples_for 'null_nilkey_booleanvalue' do
it 'reads from keys like a Hash' do
store[0].should be_nil
@@ -1100,10 +2176,22 @@
store[0] = true
store[0].should == true
store[0] = false
store[0].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = true
+ store[0].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = true
store.fetch(0, false).should == true
end
@@ -1151,10 +2239,22 @@
store[nil] = true
store[nil].should == true
store[nil] = false
store[nil].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = true
+ store[nil].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = true
store.fetch(nil, false).should == true
end
@@ -1202,10 +2302,22 @@
store[0] = false
store[0].should == false
store[0] = true
store[0].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = false
+ store[0].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = false
store.fetch(0, true).should == false
end
@@ -1253,10 +2365,22 @@
store[nil] = false
store[nil].should == false
store[nil] = true
store[nil].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = false
+ store[nil].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = false
store.fetch(nil, true).should == false
end
@@ -1548,10 +2672,22 @@
store[0] = "strval1"
store[0].should == "strval1"
store[0] = "strval2"
store[0].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[0] = value).should equal(value)
+ store[0].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = "strval1"
+ store[0].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = "strval1"
store.fetch(0, "strval2").should == "strval1"
end
@@ -1599,10 +2735,22 @@
store[nil] = "strval1"
store[nil].should == "strval1"
store[nil] = "strval2"
store[nil].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = "strval1"
+ store[nil].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = "strval1"
store.fetch(nil, "strval2").should == "strval1"
end
@@ -1650,10 +2798,22 @@
store[0] = "strval2"
store[0].should == "strval2"
store[0] = "strval1"
store[0].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[0] = value).should equal(value)
+ store[0].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = "strval2"
+ store[0].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = "strval2"
store.fetch(0, "strval1").should == "strval2"
end
@@ -1701,10 +2861,22 @@
store[nil] = "strval2"
store[nil].should == "strval2"
store[nil] = "strval1"
store[nil].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = "strval2"
+ store[nil].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = "strval2"
store.fetch(nil, "strval1").should == "strval2"
end
@@ -2052,10 +3224,22 @@
store[0] = {"hashval1"=>["array1", 1]}
store[0].should == {"hashval1"=>["array1", 1]}
store[0] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[0].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[0].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = {"hashval1"=>["array1", 1]}
store.fetch(0, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -2103,10 +3287,22 @@
store[nil] = {"hashval1"=>["array1", 1]}
store[nil].should == {"hashval1"=>["array1", 1]}
store[nil] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[nil].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[nil].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = {"hashval1"=>["array1", 1]}
store.fetch(nil, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -2154,10 +3350,22 @@
store[0] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[0].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[0] = {"hashval1"=>["array1", 1]}
store[0].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[0] = value).should equal(value)
+ store[0].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(0, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -2205,10 +3413,22 @@
store[nil] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[nil].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[nil] = {"hashval1"=>["array1", 1]}
store[nil].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[nil].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(nil, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -2556,10 +3776,22 @@
store[0] = Value.new(:objval1)
store[0].should == Value.new(:objval1)
store[0] = Value.new(:objval2)
store[0].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[0] = value).should equal(value)
+ store[0].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = Value.new(:objval1)
+ store[0].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = Value.new(:objval1)
store.fetch(0, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -2607,10 +3839,22 @@
store[nil] = Value.new(:objval1)
store[nil].should == Value.new(:objval1)
store[nil] = Value.new(:objval2)
store[nil].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = Value.new(:objval1)
+ store[nil].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = Value.new(:objval1)
store.fetch(nil, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -2658,10 +3902,22 @@
store[0] = Value.new(:objval2)
store[0].should == Value.new(:objval2)
store[0] = Value.new(:objval1)
store[0].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[0] = value).should equal(value)
+ store[0].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = 0.freeze
+ store[key] = Value.new(:objval2)
+ store[0].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[0] = Value.new(:objval2)
store.fetch(0, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -2709,10 +3965,22 @@
store[nil] = Value.new(:objval2)
store[nil].should == Value.new(:objval2)
store[nil] = Value.new(:objval1)
store[nil].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[nil] = value).should equal(value)
+ store[nil].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = nil.freeze
+ store[key] = Value.new(:objval2)
+ store[nil].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[nil] = Value.new(:objval2)
store.fetch(nil, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -3061,10 +4329,22 @@
store[-10].should == 0
store[-10] = nil
store[-10].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = 0
+ store[-10].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[42] = 0
store[42].should == 0
store.load(42).should == 0
end
@@ -3101,10 +4381,22 @@
store[42].should == 0
store[42] = nil
store[42].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = 0
+ store[42].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[-10] = nil
store[-10].should == nil
store.load(-10).should == nil
end
@@ -3141,10 +4433,22 @@
store[-10].should == nil
store[-10] = 0
store[-10].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = nil
+ store[-10].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store[42] = nil
store[42].should == nil
store.load(42).should == nil
end
@@ -3180,10 +4484,22 @@
store[42] = nil
store[42].should == nil
store[42] = 0
store[42].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = nil
+ store[42].should == nil
+ end
end
#################### persist_integerkey_nilvalue ####################
shared_examples_for 'persist_integerkey_nilvalue' do
@@ -3464,10 +4780,22 @@
store[-10] = 41
store[-10].should == 41
store[-10] = -12
store[-10].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = 41
+ store[-10].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = 41
store.fetch(-10, -12).should == 41
end
@@ -3515,10 +4843,22 @@
store[42] = 41
store[42].should == 41
store[42] = -12
store[42].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = 41
+ store[42].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = 41
store.fetch(42, -12).should == 41
end
@@ -3566,10 +4906,22 @@
store[-10] = -12
store[-10].should == -12
store[-10] = 41
store[-10].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = -12
+ store[-10].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = -12
store.fetch(-10, 41).should == -12
end
@@ -3617,10 +4969,22 @@
store[42] = -12
store[42].should == -12
store[42] = 41
store[42].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = -12
+ store[42].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = -12
store.fetch(42, 41).should == -12
end
@@ -3662,10 +5026,990 @@
@store = nil
store[42].should == -12
end
end
+#################### null_integerkey_numbervalue ####################
+
+shared_examples_for 'null_integerkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[-10].should be_nil
+ store.load(-10).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[-10] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-10).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-10).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-10] = 123.456
+ store[42] = -98.7
+ store.clear.should equal(store)
+ store.key?(-10).should be_false
+ store.key?(42).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-10, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -10
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-10, options).should be_false
+ store.load(-10, options).should be_nil
+ store.fetch(-10, 42, options).should == 42
+ store.fetch(-10, options) { 42 }.should == 42
+ store.delete(-10, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-10, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[42].should be_nil
+ store.load(42).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[42] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(42).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(42).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[42] = 123.456
+ store[-10] = -98.7
+ store.clear.should equal(store)
+ store.key?(42).should be_false
+ store.key?(-10).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(42, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 42
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(42, options).should be_false
+ store.load(42, options).should be_nil
+ store.fetch(42, 42, options).should == 42
+ store.fetch(42, options) { 42 }.should == 42
+ store.delete(42, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(42, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-10].should be_nil
+ store.load(-10).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[-10] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-10).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-10).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-10] = -98.7
+ store[42] = 123.456
+ store.clear.should equal(store)
+ store.key?(-10).should be_false
+ store.key?(42).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-10, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -10
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-10, options).should be_false
+ store.load(-10, options).should be_nil
+ store.fetch(-10, 42, options).should == 42
+ store.fetch(-10, options) { 42 }.should == 42
+ store.delete(-10, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-10, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[42].should be_nil
+ store.load(42).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[42] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(42).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(42).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[42] = -98.7
+ store[-10] = 123.456
+ store.clear.should equal(store)
+ store.key?(42).should be_false
+ store.key?(-10).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(42, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 42
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(42, options).should be_false
+ store.load(42, options).should be_nil
+ store.fetch(42, 42, options).should == 42
+ store.fetch(42, options) { 42 }.should == 42
+ store.delete(42, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(42, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-10].should be_nil
+ store.load(-10).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[-10] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-10).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-10).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-10] = 340282366920938463463374607431768211456
+ store[42] = 33
+ store.clear.should equal(store)
+ store.key?(-10).should be_false
+ store.key?(42).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-10, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -10
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-10, options).should be_false
+ store.load(-10, options).should be_nil
+ store.fetch(-10, 42, options).should == 42
+ store.fetch(-10, options) { 42 }.should == 42
+ store.delete(-10, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-10, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[42].should be_nil
+ store.load(42).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[42] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(42).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(42).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[42] = 340282366920938463463374607431768211456
+ store[-10] = 33
+ store.clear.should equal(store)
+ store.key?(42).should be_false
+ store.key?(-10).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(42, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 42
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(42, options).should be_false
+ store.load(42, options).should be_nil
+ store.fetch(42, 42, options).should == 42
+ store.fetch(42, options) { 42 }.should == 42
+ store.delete(42, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(42, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-10].should be_nil
+ store.load(-10).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[-10] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-10).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-10).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-10] = 33
+ store[42] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(-10).should be_false
+ store.key?(42).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-10, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -10
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-10, options).should be_false
+ store.load(-10, options).should be_nil
+ store.fetch(-10, 42, options).should == 42
+ store.fetch(-10, options) { 42 }.should == 42
+ store.delete(-10, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-10, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[42].should be_nil
+ store.load(42).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[42] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(42).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(42).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[42] = 33
+ store[-10] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(42).should be_false
+ store.key?(-10).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(42, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 42
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(42, options).should be_false
+ store.load(42, options).should be_nil
+ store.fetch(42, 42, options).should == 42
+ store.fetch(42, options) { 42 }.should == 42
+ store.delete(42, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(42, 33, options).should == 33
+ end
+end
+
+#################### store_integerkey_numbervalue ####################
+
+shared_examples_for 'store_integerkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[-10] = 123.456
+ store[-10].should == 123.456
+ store.load(-10).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-10] = 123.456
+ store.key?(-10).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(-10, value).should equal(value)
+ store[-10].should == 123.456
+ store.load(-10).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[-10] = 123.456
+ store[42] = -98.7
+ store.clear.should equal(store)
+ store[-10] = 123.456
+ store[-10].should == 123.456
+ store[42].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-10] = 123.456
+ store.delete(-10).should == 123.456
+ store.key?(-10).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-10] = 123.456
+ store[-10].should == 123.456
+ store[-10] = -98.7
+ store[-10].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = 123.456
+ store[-10].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-10] = 123.456
+ store.fetch(-10, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-10] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(-10) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[42] = 123.456
+ store[42].should == 123.456
+ store.load(42).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[42] = 123.456
+ store.key?(42).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(42, value).should equal(value)
+ store[42].should == 123.456
+ store.load(42).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[42] = 123.456
+ store[-10] = -98.7
+ store.clear.should equal(store)
+ store[42] = 123.456
+ store[42].should == 123.456
+ store[-10].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[42] = 123.456
+ store.delete(42).should == 123.456
+ store.key?(42).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[42] = 123.456
+ store[42].should == 123.456
+ store[42] = -98.7
+ store[42].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = 123.456
+ store[42].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[42] = 123.456
+ store.fetch(42, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[42] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(42) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-10] = -98.7
+ store[-10].should == -98.7
+ store.load(-10).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-10] = -98.7
+ store.key?(-10).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(-10, value).should equal(value)
+ store[-10].should == -98.7
+ store.load(-10).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[-10] = -98.7
+ store[42] = 123.456
+ store.clear.should equal(store)
+ store[-10] = -98.7
+ store[-10].should == -98.7
+ store[42].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-10] = -98.7
+ store.delete(-10).should == -98.7
+ store.key?(-10).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-10] = -98.7
+ store[-10].should == -98.7
+ store[-10] = 123.456
+ store[-10].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = -98.7
+ store[-10].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-10] = -98.7
+ store.fetch(-10, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-10] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(-10) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[42] = -98.7
+ store[42].should == -98.7
+ store.load(42).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[42] = -98.7
+ store.key?(42).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(42, value).should equal(value)
+ store[42].should == -98.7
+ store.load(42).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[42] = -98.7
+ store[-10] = 123.456
+ store.clear.should equal(store)
+ store[42] = -98.7
+ store[42].should == -98.7
+ store[-10].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[42] = -98.7
+ store.delete(42).should == -98.7
+ store.key?(42).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[42] = -98.7
+ store[42].should == -98.7
+ store[42] = 123.456
+ store[42].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = -98.7
+ store[42].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[42] = -98.7
+ store.fetch(42, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[42] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(42) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-10] = 340282366920938463463374607431768211456
+ store[-10].should == 340282366920938463463374607431768211456
+ store.load(-10).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-10] = 340282366920938463463374607431768211456
+ store.key?(-10).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(-10, value).should equal(value)
+ store[-10].should == 340282366920938463463374607431768211456
+ store.load(-10).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[-10] = 340282366920938463463374607431768211456
+ store[42] = 33
+ store.clear.should equal(store)
+ store[-10] = 340282366920938463463374607431768211456
+ store[-10].should == 340282366920938463463374607431768211456
+ store[42].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-10] = 340282366920938463463374607431768211456
+ store.delete(-10).should == 340282366920938463463374607431768211456
+ store.key?(-10).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-10] = 340282366920938463463374607431768211456
+ store[-10].should == 340282366920938463463374607431768211456
+ store[-10] = 33
+ store[-10].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[-10].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-10] = 340282366920938463463374607431768211456
+ store.fetch(-10, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-10] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(-10) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[42] = 340282366920938463463374607431768211456
+ store[42].should == 340282366920938463463374607431768211456
+ store.load(42).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[42] = 340282366920938463463374607431768211456
+ store.key?(42).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(42, value).should equal(value)
+ store[42].should == 340282366920938463463374607431768211456
+ store.load(42).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[42] = 340282366920938463463374607431768211456
+ store[-10] = 33
+ store.clear.should equal(store)
+ store[42] = 340282366920938463463374607431768211456
+ store[42].should == 340282366920938463463374607431768211456
+ store[-10].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[42] = 340282366920938463463374607431768211456
+ store.delete(42).should == 340282366920938463463374607431768211456
+ store.key?(42).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[42] = 340282366920938463463374607431768211456
+ store[42].should == 340282366920938463463374607431768211456
+ store[42] = 33
+ store[42].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[42].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[42] = 340282366920938463463374607431768211456
+ store.fetch(42, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[42] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(42) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-10] = 33
+ store[-10].should == 33
+ store.load(-10).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-10] = 33
+ store.key?(-10).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(-10, value).should equal(value)
+ store[-10].should == 33
+ store.load(-10).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[-10] = 33
+ store[42] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[-10] = 33
+ store[-10].should == 33
+ store[42].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-10] = 33
+ store.delete(-10).should == 33
+ store.key?(-10).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-10] = 33
+ store[-10].should == 33
+ store[-10] = 340282366920938463463374607431768211456
+ store[-10].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = 33
+ store[-10].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-10] = 33
+ store.fetch(-10, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-10] = 33
+ unaltered = 'unaltered'
+ store.fetch(-10) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[42] = 33
+ store[42].should == 33
+ store.load(42).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[42] = 33
+ store.key?(42).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(42, value).should equal(value)
+ store[42].should == 33
+ store.load(42).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[42] = 33
+ store[-10] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[42] = 33
+ store[42].should == 33
+ store[-10].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[42] = 33
+ store.delete(42).should == 33
+ store.key?(42).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[42] = 33
+ store[42].should == 33
+ store[42] = 340282366920938463463374607431768211456
+ store[42].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = 33
+ store[42].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[42] = 33
+ store.fetch(42, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[42] = 33
+ unaltered = 'unaltered'
+ store.fetch(42) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_integerkey_numbervalue ####################
+
+shared_examples_for 'persist_integerkey_numbervalue' do
+ it 'persists values' do
+ store[-10] = 123.456
+ store.close
+ @store = nil
+ store[-10].should == 123.456
+ end
+
+ it 'persists values' do
+ store[42] = 123.456
+ store.close
+ @store = nil
+ store[42].should == 123.456
+ end
+
+ it 'persists values' do
+ store[-10] = -98.7
+ store.close
+ @store = nil
+ store[-10].should == -98.7
+ end
+
+ it 'persists values' do
+ store[42] = -98.7
+ store.close
+ @store = nil
+ store[42].should == -98.7
+ end
+
+ it 'persists values' do
+ store[-10] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[-10].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[42] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[42].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[-10] = 33
+ store.close
+ @store = nil
+ store[-10].should == 33
+ end
+
+ it 'persists values' do
+ store[42] = 33
+ store.close
+ @store = nil
+ store[42].should == 33
+ end
+end
+
#################### null_integerkey_booleanvalue ####################
shared_examples_for 'null_integerkey_booleanvalue' do
it 'reads from keys like a Hash' do
store[-10].should be_nil
@@ -3912,10 +6256,22 @@
store[-10] = true
store[-10].should == true
store[-10] = false
store[-10].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = true
+ store[-10].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = true
store.fetch(-10, false).should == true
end
@@ -3963,10 +6319,22 @@
store[42] = true
store[42].should == true
store[42] = false
store[42].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = true
+ store[42].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = true
store.fetch(42, false).should == true
end
@@ -4014,10 +6382,22 @@
store[-10] = false
store[-10].should == false
store[-10] = true
store[-10].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = false
+ store[-10].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = false
store.fetch(-10, true).should == false
end
@@ -4065,10 +6445,22 @@
store[42] = false
store[42].should == false
store[42] = true
store[42].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = false
+ store[42].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = false
store.fetch(42, true).should == false
end
@@ -4360,10 +6752,22 @@
store[-10] = "strval1"
store[-10].should == "strval1"
store[-10] = "strval2"
store[-10].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = "strval1"
+ store[-10].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = "strval1"
store.fetch(-10, "strval2").should == "strval1"
end
@@ -4411,10 +6815,22 @@
store[42] = "strval1"
store[42].should == "strval1"
store[42] = "strval2"
store[42].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[42] = value).should equal(value)
+ store[42].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = "strval1"
+ store[42].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = "strval1"
store.fetch(42, "strval2").should == "strval1"
end
@@ -4462,10 +6878,22 @@
store[-10] = "strval2"
store[-10].should == "strval2"
store[-10] = "strval1"
store[-10].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = "strval2"
+ store[-10].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = "strval2"
store.fetch(-10, "strval1").should == "strval2"
end
@@ -4513,10 +6941,22 @@
store[42] = "strval2"
store[42].should == "strval2"
store[42] = "strval1"
store[42].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[42] = value).should equal(value)
+ store[42].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = "strval2"
+ store[42].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = "strval2"
store.fetch(42, "strval1").should == "strval2"
end
@@ -4864,10 +7304,22 @@
store[-10] = {"hashval1"=>["array1", 1]}
store[-10].should == {"hashval1"=>["array1", 1]}
store[-10] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[-10].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[-10].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = {"hashval1"=>["array1", 1]}
store.fetch(-10, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -4915,10 +7367,22 @@
store[42] = {"hashval1"=>["array1", 1]}
store[42].should == {"hashval1"=>["array1", 1]}
store[42] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[42].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[42].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = {"hashval1"=>["array1", 1]}
store.fetch(42, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -4966,10 +7430,22 @@
store[-10] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[-10].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[-10] = {"hashval1"=>["array1", 1]}
store[-10].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-10].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(-10, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -5017,10 +7493,22 @@
store[42] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[42].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[42] = {"hashval1"=>["array1", 1]}
store[42].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[42] = value).should equal(value)
+ store[42].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[42].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(42, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -5368,10 +7856,22 @@
store[-10] = Value.new(:objval1)
store[-10].should == Value.new(:objval1)
store[-10] = Value.new(:objval2)
store[-10].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = Value.new(:objval1)
+ store[-10].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = Value.new(:objval1)
store.fetch(-10, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -5419,10 +7919,22 @@
store[42] = Value.new(:objval1)
store[42].should == Value.new(:objval1)
store[42] = Value.new(:objval2)
store[42].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[42] = value).should equal(value)
+ store[42].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = Value.new(:objval1)
+ store[42].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = Value.new(:objval1)
store.fetch(42, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -5470,10 +7982,22 @@
store[-10] = Value.new(:objval2)
store[-10].should == Value.new(:objval2)
store[-10] = Value.new(:objval1)
store[-10].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[-10] = value).should equal(value)
+ store[-10].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = -10.freeze
+ store[key] = Value.new(:objval2)
+ store[-10].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[-10] = Value.new(:objval2)
store.fetch(-10, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -5521,10 +8045,22 @@
store[42] = Value.new(:objval2)
store[42].should == Value.new(:objval2)
store[42] = Value.new(:objval1)
store[42].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[42] = value).should equal(value)
+ store[42].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = 42.freeze
+ store[key] = Value.new(:objval2)
+ store[42].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[42] = Value.new(:objval2)
store.fetch(42, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -5622,10 +8158,8062 @@
@store = nil
store[42].should == Value.new(:objval2)
end
end
+#################### null_numberkey_nilvalue ####################
+
+shared_examples_for 'null_numberkey_nilvalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = 0
+ store[-0.3] = nil
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = 0
+ store[0.5] = nil
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = nil
+ store[-0.3] = 0
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, nil, options).should == nil
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = nil
+ store[0.5] = 0
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, nil, options).should == nil
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = 0
+ store[99] = nil
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = 0
+ store[170141183460469231731687303715884105728] = nil
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = nil
+ store[99] = 0
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, nil, options).should == nil
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = nil
+ store[170141183460469231731687303715884105728] = 0
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, nil, options).should == nil
+ end
+end
+
+#################### store_numberkey_nilvalue ####################
+
+shared_examples_for 'store_numberkey_nilvalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = 0
+ store[0.5].should == 0
+ store.load(0.5).should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = 0
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == 0
+ store.load(0.5).should == 0
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = 0
+ store[-0.3] = nil
+ store.clear.should equal(store)
+ store[0.5] = 0
+ store[0.5].should == 0
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = 0
+ store.delete(0.5).should == 0
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = 0
+ store[0.5].should == 0
+ store[0.5] = nil
+ store[0.5].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = 0
+ store[0.5].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = 0
+ store[-0.3].should == 0
+ store.load(-0.3).should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = 0
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == 0
+ store.load(-0.3).should == 0
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = 0
+ store[0.5] = nil
+ store.clear.should equal(store)
+ store[-0.3] = 0
+ store[-0.3].should == 0
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = 0
+ store.delete(-0.3).should == 0
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = 0
+ store[-0.3].should == 0
+ store[-0.3] = nil
+ store[-0.3].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = 0
+ store[-0.3].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = nil
+ store[0.5].should == nil
+ store.load(0.5).should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = nil
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == nil
+ store.load(0.5).should == nil
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = nil
+ store[-0.3] = 0
+ store.clear.should equal(store)
+ store[0.5] = nil
+ store[0.5].should == nil
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = nil
+ store.delete(0.5).should == nil
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = nil
+ store[0.5].should == nil
+ store[0.5] = 0
+ store[0.5].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = nil
+ store[0.5].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = nil
+ store[-0.3].should == nil
+ store.load(-0.3).should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = nil
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == nil
+ store.load(-0.3).should == nil
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = nil
+ store[0.5] = 0
+ store.clear.should equal(store)
+ store[-0.3] = nil
+ store[-0.3].should == nil
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = nil
+ store.delete(-0.3).should == nil
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = nil
+ store[-0.3].should == nil
+ store[-0.3] = 0
+ store[-0.3].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = nil
+ store[-0.3].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = 0
+ store[170141183460469231731687303715884105728].should == 0
+ store.load(170141183460469231731687303715884105728).should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = 0
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 0
+ store.load(170141183460469231731687303715884105728).should == 0
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = 0
+ store[99] = nil
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = 0
+ store[170141183460469231731687303715884105728].should == 0
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = 0
+ store.delete(170141183460469231731687303715884105728).should == 0
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = 0
+ store[170141183460469231731687303715884105728].should == 0
+ store[170141183460469231731687303715884105728] = nil
+ store[170141183460469231731687303715884105728].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = 0
+ store[170141183460469231731687303715884105728].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = 0
+ store[99].should == 0
+ store.load(99).should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = 0
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store(99, value).should equal(value)
+ store[99].should == 0
+ store.load(99).should == 0
+ end
+
+ it 'stores values after clear' do
+ store[99] = 0
+ store[170141183460469231731687303715884105728] = nil
+ store.clear.should equal(store)
+ store[99] = 0
+ store[99].should == 0
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = 0
+ store.delete(99).should == 0
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = 0
+ store[99].should == 0
+ store[99] = nil
+ store[99].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = 0
+ store[99].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = nil
+ store[170141183460469231731687303715884105728].should == nil
+ store.load(170141183460469231731687303715884105728).should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = nil
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == nil
+ store.load(170141183460469231731687303715884105728).should == nil
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = nil
+ store[99] = 0
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = nil
+ store[170141183460469231731687303715884105728].should == nil
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = nil
+ store.delete(170141183460469231731687303715884105728).should == nil
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = nil
+ store[170141183460469231731687303715884105728].should == nil
+ store[170141183460469231731687303715884105728] = 0
+ store[170141183460469231731687303715884105728].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = nil
+ store[170141183460469231731687303715884105728].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = nil
+ store[99].should == nil
+ store.load(99).should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = nil
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store(99, value).should equal(value)
+ store[99].should == nil
+ store.load(99).should == nil
+ end
+
+ it 'stores values after clear' do
+ store[99] = nil
+ store[170141183460469231731687303715884105728] = 0
+ store.clear.should equal(store)
+ store[99] = nil
+ store[99].should == nil
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = nil
+ store.delete(99).should == nil
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = nil
+ store[99].should == nil
+ store[99] = 0
+ store[99].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = nil
+ store[99].should == nil
+ end
+end
+
+#################### persist_numberkey_nilvalue ####################
+
+shared_examples_for 'persist_numberkey_nilvalue' do
+ it 'persists values' do
+ store[0.5] = 0
+ store.close
+ @store = nil
+ store[0.5].should == 0
+ end
+
+ it 'persists values' do
+ store[-0.3] = 0
+ store.close
+ @store = nil
+ store[-0.3].should == 0
+ end
+
+ it 'persists values' do
+ store[0.5] = nil
+ store.close
+ @store = nil
+ store[0.5].should == nil
+ end
+
+ it 'persists values' do
+ store[-0.3] = nil
+ store.close
+ @store = nil
+ store[-0.3].should == nil
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = 0
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == 0
+ end
+
+ it 'persists values' do
+ store[99] = 0
+ store.close
+ @store = nil
+ store[99].should == 0
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = nil
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == nil
+ end
+
+ it 'persists values' do
+ store[99] = nil
+ store.close
+ @store = nil
+ store[99].should == nil
+ end
+end
+
+#################### null_numberkey_integervalue ####################
+
+shared_examples_for 'null_numberkey_integervalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = 41
+ store[-0.3] = -12
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = 41
+ store[0.5] = -12
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = -12
+ store[-0.3] = 41
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, -12, options).should == -12
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = -12
+ store[0.5] = 41
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, -12, options).should == -12
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = 41
+ store[99] = -12
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = 41
+ store[170141183460469231731687303715884105728] = -12
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = -12
+ store[99] = 41
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, -12, options).should == -12
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = -12
+ store[170141183460469231731687303715884105728] = 41
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, -12, options).should == -12
+ end
+end
+
+#################### store_numberkey_integervalue ####################
+
+shared_examples_for 'store_numberkey_integervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = 41
+ store[0.5].should == 41
+ store.load(0.5).should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = 41
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == 41
+ store.load(0.5).should == 41
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = 41
+ store[-0.3] = -12
+ store.clear.should equal(store)
+ store[0.5] = 41
+ store[0.5].should == 41
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = 41
+ store.delete(0.5).should == 41
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = 41
+ store[0.5].should == 41
+ store[0.5] = -12
+ store[0.5].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = 41
+ store[0.5].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = 41
+ store.fetch(0.5, -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = 41
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = 41
+ store[-0.3].should == 41
+ store.load(-0.3).should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = 41
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == 41
+ store.load(-0.3).should == 41
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = 41
+ store[0.5] = -12
+ store.clear.should equal(store)
+ store[-0.3] = 41
+ store[-0.3].should == 41
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = 41
+ store.delete(-0.3).should == 41
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = 41
+ store[-0.3].should == 41
+ store[-0.3] = -12
+ store[-0.3].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = 41
+ store[-0.3].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = 41
+ store.fetch(-0.3, -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = 41
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = -12
+ store[0.5].should == -12
+ store.load(0.5).should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = -12
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == -12
+ store.load(0.5).should == -12
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = -12
+ store[-0.3] = 41
+ store.clear.should equal(store)
+ store[0.5] = -12
+ store[0.5].should == -12
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = -12
+ store.delete(0.5).should == -12
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = -12
+ store[0.5].should == -12
+ store[0.5] = 41
+ store[0.5].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = -12
+ store[0.5].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = -12
+ store.fetch(0.5, 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = -12
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = -12
+ store[-0.3].should == -12
+ store.load(-0.3).should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = -12
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == -12
+ store.load(-0.3).should == -12
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = -12
+ store[0.5] = 41
+ store.clear.should equal(store)
+ store[-0.3] = -12
+ store[-0.3].should == -12
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = -12
+ store.delete(-0.3).should == -12
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = -12
+ store[-0.3].should == -12
+ store[-0.3] = 41
+ store[-0.3].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = -12
+ store[-0.3].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = -12
+ store.fetch(-0.3, 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = -12
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = 41
+ store[170141183460469231731687303715884105728].should == 41
+ store.load(170141183460469231731687303715884105728).should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = 41
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 41
+ store.load(170141183460469231731687303715884105728).should == 41
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = 41
+ store[99] = -12
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = 41
+ store[170141183460469231731687303715884105728].should == 41
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = 41
+ store.delete(170141183460469231731687303715884105728).should == 41
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = 41
+ store[170141183460469231731687303715884105728].should == 41
+ store[170141183460469231731687303715884105728] = -12
+ store[170141183460469231731687303715884105728].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = 41
+ store[170141183460469231731687303715884105728].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = 41
+ store.fetch(170141183460469231731687303715884105728, -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = 41
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = 41
+ store[99].should == 41
+ store.load(99).should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = 41
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store(99, value).should equal(value)
+ store[99].should == 41
+ store.load(99).should == 41
+ end
+
+ it 'stores values after clear' do
+ store[99] = 41
+ store[170141183460469231731687303715884105728] = -12
+ store.clear.should equal(store)
+ store[99] = 41
+ store[99].should == 41
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = 41
+ store.delete(99).should == 41
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = 41
+ store[99].should == 41
+ store[99] = -12
+ store[99].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = 41
+ store[99].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = 41
+ store.fetch(99, -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = 41
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = -12
+ store[170141183460469231731687303715884105728].should == -12
+ store.load(170141183460469231731687303715884105728).should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = -12
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == -12
+ store.load(170141183460469231731687303715884105728).should == -12
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = -12
+ store[99] = 41
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = -12
+ store[170141183460469231731687303715884105728].should == -12
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = -12
+ store.delete(170141183460469231731687303715884105728).should == -12
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = -12
+ store[170141183460469231731687303715884105728].should == -12
+ store[170141183460469231731687303715884105728] = 41
+ store[170141183460469231731687303715884105728].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = -12
+ store[170141183460469231731687303715884105728].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = -12
+ store.fetch(170141183460469231731687303715884105728, 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = -12
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = -12
+ store[99].should == -12
+ store.load(99).should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = -12
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store(99, value).should equal(value)
+ store[99].should == -12
+ store.load(99).should == -12
+ end
+
+ it 'stores values after clear' do
+ store[99] = -12
+ store[170141183460469231731687303715884105728] = 41
+ store.clear.should equal(store)
+ store[99] = -12
+ store[99].should == -12
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = -12
+ store.delete(99).should == -12
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = -12
+ store[99].should == -12
+ store[99] = 41
+ store[99].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = -12
+ store[99].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = -12
+ store.fetch(99, 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = -12
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_numberkey_integervalue ####################
+
+shared_examples_for 'persist_numberkey_integervalue' do
+ it 'persists values' do
+ store[0.5] = 41
+ store.close
+ @store = nil
+ store[0.5].should == 41
+ end
+
+ it 'persists values' do
+ store[-0.3] = 41
+ store.close
+ @store = nil
+ store[-0.3].should == 41
+ end
+
+ it 'persists values' do
+ store[0.5] = -12
+ store.close
+ @store = nil
+ store[0.5].should == -12
+ end
+
+ it 'persists values' do
+ store[-0.3] = -12
+ store.close
+ @store = nil
+ store[-0.3].should == -12
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = 41
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == 41
+ end
+
+ it 'persists values' do
+ store[99] = 41
+ store.close
+ @store = nil
+ store[99].should == 41
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = -12
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == -12
+ end
+
+ it 'persists values' do
+ store[99] = -12
+ store.close
+ @store = nil
+ store[99].should == -12
+ end
+end
+
+#################### null_numberkey_numbervalue ####################
+
+shared_examples_for 'null_numberkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = 123.456
+ store[-0.3] = -98.7
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = 123.456
+ store[0.5] = -98.7
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = -98.7
+ store[-0.3] = 123.456
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = -98.7
+ store[0.5] = 123.456
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store[-0.3] = 33
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[0.5] = 33
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = 33
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = 33
+ store[0.5] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store[99] = -98.7
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = 123.456
+ store[170141183460469231731687303715884105728] = -98.7
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store[99] = 123.456
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = -98.7
+ store[170141183460469231731687303715884105728] = 123.456
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[99] = 33
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728] = 33
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = 33
+ store[99] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = 33
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, 33, options).should == 33
+ end
+end
+
+#################### store_numberkey_numbervalue ####################
+
+shared_examples_for 'store_numberkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = 123.456
+ store[0.5].should == 123.456
+ store.load(0.5).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = 123.456
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == 123.456
+ store.load(0.5).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = 123.456
+ store[-0.3] = -98.7
+ store.clear.should equal(store)
+ store[0.5] = 123.456
+ store[0.5].should == 123.456
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = 123.456
+ store.delete(0.5).should == 123.456
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = 123.456
+ store[0.5].should == 123.456
+ store[0.5] = -98.7
+ store[0.5].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = 123.456
+ store[0.5].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = 123.456
+ store.fetch(0.5, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = 123.456
+ store[-0.3].should == 123.456
+ store.load(-0.3).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = 123.456
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == 123.456
+ store.load(-0.3).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = 123.456
+ store[0.5] = -98.7
+ store.clear.should equal(store)
+ store[-0.3] = 123.456
+ store[-0.3].should == 123.456
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = 123.456
+ store.delete(-0.3).should == 123.456
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = 123.456
+ store[-0.3].should == 123.456
+ store[-0.3] = -98.7
+ store[-0.3].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = 123.456
+ store[-0.3].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = 123.456
+ store.fetch(-0.3, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = -98.7
+ store[0.5].should == -98.7
+ store.load(0.5).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = -98.7
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == -98.7
+ store.load(0.5).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = -98.7
+ store[-0.3] = 123.456
+ store.clear.should equal(store)
+ store[0.5] = -98.7
+ store[0.5].should == -98.7
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = -98.7
+ store.delete(0.5).should == -98.7
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = -98.7
+ store[0.5].should == -98.7
+ store[0.5] = 123.456
+ store[0.5].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = -98.7
+ store[0.5].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = -98.7
+ store.fetch(0.5, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = -98.7
+ store[-0.3].should == -98.7
+ store.load(-0.3).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = -98.7
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == -98.7
+ store.load(-0.3).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = -98.7
+ store[0.5] = 123.456
+ store.clear.should equal(store)
+ store[-0.3] = -98.7
+ store[-0.3].should == -98.7
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = -98.7
+ store.delete(-0.3).should == -98.7
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = -98.7
+ store[-0.3].should == -98.7
+ store[-0.3] = 123.456
+ store[-0.3].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = -98.7
+ store[-0.3].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = -98.7
+ store.fetch(-0.3, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store[0.5].should == 340282366920938463463374607431768211456
+ store.load(0.5).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == 340282366920938463463374607431768211456
+ store.load(0.5).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store[-0.3] = 33
+ store.clear.should equal(store)
+ store[0.5] = 340282366920938463463374607431768211456
+ store[0.5].should == 340282366920938463463374607431768211456
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store.delete(0.5).should == 340282366920938463463374607431768211456
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store[0.5].should == 340282366920938463463374607431768211456
+ store[0.5] = 33
+ store[0.5].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[0.5].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store.fetch(0.5, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[-0.3].should == 340282366920938463463374607431768211456
+ store.load(-0.3).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == 340282366920938463463374607431768211456
+ store.load(-0.3).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[0.5] = 33
+ store.clear.should equal(store)
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[-0.3].should == 340282366920938463463374607431768211456
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.delete(-0.3).should == 340282366920938463463374607431768211456
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[-0.3].should == 340282366920938463463374607431768211456
+ store[-0.3] = 33
+ store[-0.3].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[-0.3].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.fetch(-0.3, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = 33
+ store[0.5].should == 33
+ store.load(0.5).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = 33
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == 33
+ store.load(0.5).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = 33
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[0.5] = 33
+ store[0.5].should == 33
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = 33
+ store.delete(0.5).should == 33
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = 33
+ store[0.5].should == 33
+ store[0.5] = 340282366920938463463374607431768211456
+ store[0.5].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = 33
+ store[0.5].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = 33
+ store.fetch(0.5, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = 33
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = 33
+ store[-0.3].should == 33
+ store.load(-0.3).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = 33
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == 33
+ store.load(-0.3).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = 33
+ store[0.5] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[-0.3] = 33
+ store[-0.3].should == 33
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = 33
+ store.delete(-0.3).should == 33
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = 33
+ store[-0.3].should == 33
+ store[-0.3] = 340282366920938463463374607431768211456
+ store[-0.3].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = 33
+ store[-0.3].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = 33
+ store.fetch(-0.3, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = 33
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store[170141183460469231731687303715884105728].should == 123.456
+ store.load(170141183460469231731687303715884105728).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 123.456
+ store.load(170141183460469231731687303715884105728).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store[99] = -98.7
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = 123.456
+ store[170141183460469231731687303715884105728].should == 123.456
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store.delete(170141183460469231731687303715884105728).should == 123.456
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store[170141183460469231731687303715884105728].should == 123.456
+ store[170141183460469231731687303715884105728] = -98.7
+ store[170141183460469231731687303715884105728].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = 123.456
+ store[170141183460469231731687303715884105728].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store.fetch(170141183460469231731687303715884105728, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = 123.456
+ store[99].should == 123.456
+ store.load(99).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = 123.456
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(99, value).should equal(value)
+ store[99].should == 123.456
+ store.load(99).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[99] = 123.456
+ store[170141183460469231731687303715884105728] = -98.7
+ store.clear.should equal(store)
+ store[99] = 123.456
+ store[99].should == 123.456
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = 123.456
+ store.delete(99).should == 123.456
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = 123.456
+ store[99].should == 123.456
+ store[99] = -98.7
+ store[99].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = 123.456
+ store[99].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = 123.456
+ store.fetch(99, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store[170141183460469231731687303715884105728].should == -98.7
+ store.load(170141183460469231731687303715884105728).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == -98.7
+ store.load(170141183460469231731687303715884105728).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store[99] = 123.456
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = -98.7
+ store[170141183460469231731687303715884105728].should == -98.7
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store.delete(170141183460469231731687303715884105728).should == -98.7
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store[170141183460469231731687303715884105728].should == -98.7
+ store[170141183460469231731687303715884105728] = 123.456
+ store[170141183460469231731687303715884105728].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = -98.7
+ store[170141183460469231731687303715884105728].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store.fetch(170141183460469231731687303715884105728, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = -98.7
+ store[99].should == -98.7
+ store.load(99).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = -98.7
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(99, value).should equal(value)
+ store[99].should == -98.7
+ store.load(99).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[99] = -98.7
+ store[170141183460469231731687303715884105728] = 123.456
+ store.clear.should equal(store)
+ store[99] = -98.7
+ store[99].should == -98.7
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = -98.7
+ store.delete(99).should == -98.7
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = -98.7
+ store[99].should == -98.7
+ store[99] = 123.456
+ store[99].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = -98.7
+ store[99].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = -98.7
+ store.fetch(99, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ store.load(170141183460469231731687303715884105728).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ store.load(170141183460469231731687303715884105728).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[99] = 33
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.delete(170141183460469231731687303715884105728).should == 340282366920938463463374607431768211456
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728] = 33
+ store[170141183460469231731687303715884105728].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.fetch(170141183460469231731687303715884105728, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = 340282366920938463463374607431768211456
+ store[99].should == 340282366920938463463374607431768211456
+ store.load(99).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = 340282366920938463463374607431768211456
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(99, value).should equal(value)
+ store[99].should == 340282366920938463463374607431768211456
+ store.load(99).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[99] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728] = 33
+ store.clear.should equal(store)
+ store[99] = 340282366920938463463374607431768211456
+ store[99].should == 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = 340282366920938463463374607431768211456
+ store.delete(99).should == 340282366920938463463374607431768211456
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = 340282366920938463463374607431768211456
+ store[99].should == 340282366920938463463374607431768211456
+ store[99] = 33
+ store[99].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[99].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = 340282366920938463463374607431768211456
+ store.fetch(99, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = 33
+ store[170141183460469231731687303715884105728].should == 33
+ store.load(170141183460469231731687303715884105728).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = 33
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 33
+ store.load(170141183460469231731687303715884105728).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = 33
+ store[99] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = 33
+ store[170141183460469231731687303715884105728].should == 33
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = 33
+ store.delete(170141183460469231731687303715884105728).should == 33
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = 33
+ store[170141183460469231731687303715884105728].should == 33
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = 33
+ store[170141183460469231731687303715884105728].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = 33
+ store.fetch(170141183460469231731687303715884105728, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = 33
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = 33
+ store[99].should == 33
+ store.load(99).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = 33
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(99, value).should equal(value)
+ store[99].should == 33
+ store.load(99).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[99] = 33
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[99] = 33
+ store[99].should == 33
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = 33
+ store.delete(99).should == 33
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = 33
+ store[99].should == 33
+ store[99] = 340282366920938463463374607431768211456
+ store[99].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = 33
+ store[99].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = 33
+ store.fetch(99, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = 33
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_numberkey_numbervalue ####################
+
+shared_examples_for 'persist_numberkey_numbervalue' do
+ it 'persists values' do
+ store[0.5] = 123.456
+ store.close
+ @store = nil
+ store[0.5].should == 123.456
+ end
+
+ it 'persists values' do
+ store[-0.3] = 123.456
+ store.close
+ @store = nil
+ store[-0.3].should == 123.456
+ end
+
+ it 'persists values' do
+ store[0.5] = -98.7
+ store.close
+ @store = nil
+ store[0.5].should == -98.7
+ end
+
+ it 'persists values' do
+ store[-0.3] = -98.7
+ store.close
+ @store = nil
+ store[-0.3].should == -98.7
+ end
+
+ it 'persists values' do
+ store[0.5] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[0.5].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[-0.3] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[-0.3].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[0.5] = 33
+ store.close
+ @store = nil
+ store[0.5].should == 33
+ end
+
+ it 'persists values' do
+ store[-0.3] = 33
+ store.close
+ @store = nil
+ store[-0.3].should == 33
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = 123.456
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == 123.456
+ end
+
+ it 'persists values' do
+ store[99] = 123.456
+ store.close
+ @store = nil
+ store[99].should == 123.456
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = -98.7
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == -98.7
+ end
+
+ it 'persists values' do
+ store[99] = -98.7
+ store.close
+ @store = nil
+ store[99].should == -98.7
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[99] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[99].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = 33
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == 33
+ end
+
+ it 'persists values' do
+ store[99] = 33
+ store.close
+ @store = nil
+ store[99].should == 33
+ end
+end
+
+#################### null_numberkey_booleanvalue ####################
+
+shared_examples_for 'null_numberkey_booleanvalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = true
+ store[-0.3] = false
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = true
+ store[0.5] = false
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = false
+ store[-0.3] = true
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, false, options).should == false
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = false
+ store[0.5] = true
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, false, options).should == false
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = true
+ store[99] = false
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = true
+ store[170141183460469231731687303715884105728] = false
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = false
+ store[99] = true
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, false, options).should == false
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = false
+ store[170141183460469231731687303715884105728] = true
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, false, options).should == false
+ end
+end
+
+#################### store_numberkey_booleanvalue ####################
+
+shared_examples_for 'store_numberkey_booleanvalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = true
+ store[0.5].should == true
+ store.load(0.5).should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = true
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == true
+ store.load(0.5).should == true
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = true
+ store[-0.3] = false
+ store.clear.should equal(store)
+ store[0.5] = true
+ store[0.5].should == true
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = true
+ store.delete(0.5).should == true
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = true
+ store[0.5].should == true
+ store[0.5] = false
+ store[0.5].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = true
+ store[0.5].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = true
+ store.fetch(0.5, false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = true
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = true
+ store[-0.3].should == true
+ store.load(-0.3).should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = true
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == true
+ store.load(-0.3).should == true
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = true
+ store[0.5] = false
+ store.clear.should equal(store)
+ store[-0.3] = true
+ store[-0.3].should == true
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = true
+ store.delete(-0.3).should == true
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = true
+ store[-0.3].should == true
+ store[-0.3] = false
+ store[-0.3].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = true
+ store[-0.3].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = true
+ store.fetch(-0.3, false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = true
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = false
+ store[0.5].should == false
+ store.load(0.5).should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = false
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == false
+ store.load(0.5).should == false
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = false
+ store[-0.3] = true
+ store.clear.should equal(store)
+ store[0.5] = false
+ store[0.5].should == false
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = false
+ store.delete(0.5).should == false
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = false
+ store[0.5].should == false
+ store[0.5] = true
+ store[0.5].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = false
+ store[0.5].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = false
+ store.fetch(0.5, true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = false
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = false
+ store[-0.3].should == false
+ store.load(-0.3).should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = false
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == false
+ store.load(-0.3).should == false
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = false
+ store[0.5] = true
+ store.clear.should equal(store)
+ store[-0.3] = false
+ store[-0.3].should == false
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = false
+ store.delete(-0.3).should == false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = false
+ store[-0.3].should == false
+ store[-0.3] = true
+ store[-0.3].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = false
+ store[-0.3].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = false
+ store.fetch(-0.3, true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = false
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = true
+ store[170141183460469231731687303715884105728].should == true
+ store.load(170141183460469231731687303715884105728).should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = true
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == true
+ store.load(170141183460469231731687303715884105728).should == true
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = true
+ store[99] = false
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = true
+ store[170141183460469231731687303715884105728].should == true
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = true
+ store.delete(170141183460469231731687303715884105728).should == true
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = true
+ store[170141183460469231731687303715884105728].should == true
+ store[170141183460469231731687303715884105728] = false
+ store[170141183460469231731687303715884105728].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = true
+ store[170141183460469231731687303715884105728].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = true
+ store.fetch(170141183460469231731687303715884105728, false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = true
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = true
+ store[99].should == true
+ store.load(99).should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = true
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store(99, value).should equal(value)
+ store[99].should == true
+ store.load(99).should == true
+ end
+
+ it 'stores values after clear' do
+ store[99] = true
+ store[170141183460469231731687303715884105728] = false
+ store.clear.should equal(store)
+ store[99] = true
+ store[99].should == true
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = true
+ store.delete(99).should == true
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = true
+ store[99].should == true
+ store[99] = false
+ store[99].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = true
+ store[99].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = true
+ store.fetch(99, false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = true
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = false
+ store[170141183460469231731687303715884105728].should == false
+ store.load(170141183460469231731687303715884105728).should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = false
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == false
+ store.load(170141183460469231731687303715884105728).should == false
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = false
+ store[99] = true
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = false
+ store[170141183460469231731687303715884105728].should == false
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = false
+ store.delete(170141183460469231731687303715884105728).should == false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = false
+ store[170141183460469231731687303715884105728].should == false
+ store[170141183460469231731687303715884105728] = true
+ store[170141183460469231731687303715884105728].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = false
+ store[170141183460469231731687303715884105728].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = false
+ store.fetch(170141183460469231731687303715884105728, true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = false
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = false
+ store[99].should == false
+ store.load(99).should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = false
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store(99, value).should equal(value)
+ store[99].should == false
+ store.load(99).should == false
+ end
+
+ it 'stores values after clear' do
+ store[99] = false
+ store[170141183460469231731687303715884105728] = true
+ store.clear.should equal(store)
+ store[99] = false
+ store[99].should == false
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = false
+ store.delete(99).should == false
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = false
+ store[99].should == false
+ store[99] = true
+ store[99].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = false
+ store[99].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = false
+ store.fetch(99, true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = false
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_numberkey_booleanvalue ####################
+
+shared_examples_for 'persist_numberkey_booleanvalue' do
+ it 'persists values' do
+ store[0.5] = true
+ store.close
+ @store = nil
+ store[0.5].should == true
+ end
+
+ it 'persists values' do
+ store[-0.3] = true
+ store.close
+ @store = nil
+ store[-0.3].should == true
+ end
+
+ it 'persists values' do
+ store[0.5] = false
+ store.close
+ @store = nil
+ store[0.5].should == false
+ end
+
+ it 'persists values' do
+ store[-0.3] = false
+ store.close
+ @store = nil
+ store[-0.3].should == false
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = true
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == true
+ end
+
+ it 'persists values' do
+ store[99] = true
+ store.close
+ @store = nil
+ store[99].should == true
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = false
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == false
+ end
+
+ it 'persists values' do
+ store[99] = false
+ store.close
+ @store = nil
+ store[99].should == false
+ end
+end
+
+#################### null_numberkey_stringvalue ####################
+
+shared_examples_for 'null_numberkey_stringvalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = "strval1"
+ store[-0.3] = "strval2"
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = "strval1"
+ store[0.5] = "strval2"
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = "strval2"
+ store[-0.3] = "strval1"
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, "strval2", options).should == "strval2"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = "strval2"
+ store[0.5] = "strval1"
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, "strval2", options).should == "strval2"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[99] = "strval2"
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = "strval1"
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[99] = "strval1"
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, "strval2", options).should == "strval2"
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = "strval2"
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, "strval2", options).should == "strval2"
+ end
+end
+
+#################### store_numberkey_stringvalue ####################
+
+shared_examples_for 'store_numberkey_stringvalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = "strval1"
+ store[0.5].should == "strval1"
+ store.load(0.5).should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = "strval1"
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == "strval1"
+ store.load(0.5).should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = "strval1"
+ store[-0.3] = "strval2"
+ store.clear.should equal(store)
+ store[0.5] = "strval1"
+ store[0.5].should == "strval1"
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = "strval1"
+ store.delete(0.5).should == "strval1"
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = "strval1"
+ store[0.5].should == "strval1"
+ store[0.5] = "strval2"
+ store[0.5].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = "strval1"
+ store[0.5].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = "strval1"
+ store.fetch(0.5, "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = "strval1"
+ store[-0.3].should == "strval1"
+ store.load(-0.3).should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = "strval1"
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == "strval1"
+ store.load(-0.3).should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = "strval1"
+ store[0.5] = "strval2"
+ store.clear.should equal(store)
+ store[-0.3] = "strval1"
+ store[-0.3].should == "strval1"
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = "strval1"
+ store.delete(-0.3).should == "strval1"
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = "strval1"
+ store[-0.3].should == "strval1"
+ store[-0.3] = "strval2"
+ store[-0.3].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = "strval1"
+ store[-0.3].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = "strval1"
+ store.fetch(-0.3, "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = "strval2"
+ store[0.5].should == "strval2"
+ store.load(0.5).should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = "strval2"
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == "strval2"
+ store.load(0.5).should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = "strval2"
+ store[-0.3] = "strval1"
+ store.clear.should equal(store)
+ store[0.5] = "strval2"
+ store[0.5].should == "strval2"
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = "strval2"
+ store.delete(0.5).should == "strval2"
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = "strval2"
+ store[0.5].should == "strval2"
+ store[0.5] = "strval1"
+ store[0.5].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = "strval2"
+ store[0.5].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = "strval2"
+ store.fetch(0.5, "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = "strval2"
+ store[-0.3].should == "strval2"
+ store.load(-0.3).should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = "strval2"
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == "strval2"
+ store.load(-0.3).should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = "strval2"
+ store[0.5] = "strval1"
+ store.clear.should equal(store)
+ store[-0.3] = "strval2"
+ store[-0.3].should == "strval2"
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = "strval2"
+ store.delete(-0.3).should == "strval2"
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = "strval2"
+ store[-0.3].should == "strval2"
+ store[-0.3] = "strval1"
+ store[-0.3].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = "strval2"
+ store[-0.3].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = "strval2"
+ store.fetch(-0.3, "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[170141183460469231731687303715884105728].should == "strval1"
+ store.load(170141183460469231731687303715884105728).should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == "strval1"
+ store.load(170141183460469231731687303715884105728).should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[99] = "strval2"
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[170141183460469231731687303715884105728].should == "strval1"
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.delete(170141183460469231731687303715884105728).should == "strval1"
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[170141183460469231731687303715884105728].should == "strval1"
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[170141183460469231731687303715884105728].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = "strval1"
+ store[170141183460469231731687303715884105728].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.fetch(170141183460469231731687303715884105728, "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = "strval1"
+ store[99].should == "strval1"
+ store.load(99).should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = "strval1"
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store(99, value).should equal(value)
+ store[99].should == "strval1"
+ store.load(99).should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store[99] = "strval1"
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.clear.should equal(store)
+ store[99] = "strval1"
+ store[99].should == "strval1"
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = "strval1"
+ store.delete(99).should == "strval1"
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = "strval1"
+ store[99].should == "strval1"
+ store[99] = "strval2"
+ store[99].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[99] = value).should equal(value)
+ store[99].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = "strval1"
+ store[99].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = "strval1"
+ store.fetch(99, "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[170141183460469231731687303715884105728].should == "strval2"
+ store.load(170141183460469231731687303715884105728).should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == "strval2"
+ store.load(170141183460469231731687303715884105728).should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[99] = "strval1"
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[170141183460469231731687303715884105728].should == "strval2"
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.delete(170141183460469231731687303715884105728).should == "strval2"
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store[170141183460469231731687303715884105728].should == "strval2"
+ store[170141183460469231731687303715884105728] = "strval1"
+ store[170141183460469231731687303715884105728].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = "strval2"
+ store[170141183460469231731687303715884105728].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.fetch(170141183460469231731687303715884105728, "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = "strval2"
+ store[99].should == "strval2"
+ store.load(99).should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = "strval2"
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store(99, value).should equal(value)
+ store[99].should == "strval2"
+ store.load(99).should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store[99] = "strval2"
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.clear.should equal(store)
+ store[99] = "strval2"
+ store[99].should == "strval2"
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = "strval2"
+ store.delete(99).should == "strval2"
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = "strval2"
+ store[99].should == "strval2"
+ store[99] = "strval1"
+ store[99].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[99] = value).should equal(value)
+ store[99].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = "strval2"
+ store[99].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = "strval2"
+ store.fetch(99, "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_numberkey_stringvalue ####################
+
+shared_examples_for 'returndifferent_numberkey_stringvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_numberkey_stringvalue ####################
+
+shared_examples_for 'returnsame_numberkey_stringvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+end
+
+#################### persist_numberkey_stringvalue ####################
+
+shared_examples_for 'persist_numberkey_stringvalue' do
+ it 'persists values' do
+ store[0.5] = "strval1"
+ store.close
+ @store = nil
+ store[0.5].should == "strval1"
+ end
+
+ it 'persists values' do
+ store[-0.3] = "strval1"
+ store.close
+ @store = nil
+ store[-0.3].should == "strval1"
+ end
+
+ it 'persists values' do
+ store[0.5] = "strval2"
+ store.close
+ @store = nil
+ store[0.5].should == "strval2"
+ end
+
+ it 'persists values' do
+ store[-0.3] = "strval2"
+ store.close
+ @store = nil
+ store[-0.3].should == "strval2"
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = "strval1"
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == "strval1"
+ end
+
+ it 'persists values' do
+ store[99] = "strval1"
+ store.close
+ @store = nil
+ store[99].should == "strval1"
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = "strval2"
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == "strval2"
+ end
+
+ it 'persists values' do
+ store[99] = "strval2"
+ store.close
+ @store = nil
+ store[99].should == "strval2"
+ end
+end
+
+#################### null_numberkey_hashvalue ####################
+
+shared_examples_for 'null_numberkey_hashvalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+end
+
+#################### store_numberkey_hashvalue ####################
+
+shared_examples_for 'store_numberkey_hashvalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ store.load(0.5).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ store.load(0.5).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.delete(0.5).should == {"hashval1"=>["array1", 1]}
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.fetch(0.5, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ store.load(-0.3).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ store.load(-0.3).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.delete(-0.3).should == {"hashval1"=>["array1", 1]}
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.fetch(-0.3, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(0.5).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(0.5).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete(0.5).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(0.5, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(-0.3).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(-0.3).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete(-0.3).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(-0.3, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ store.load(170141183460469231731687303715884105728).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ store.load(170141183460469231731687303715884105728).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.delete(170141183460469231731687303715884105728).should == {"hashval1"=>["array1", 1]}
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.fetch(170141183460469231731687303715884105728, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[99].should == {"hashval1"=>["array1", 1]}
+ store.load(99).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store(99, value).should equal(value)
+ store[99].should == {"hashval1"=>["array1", 1]}
+ store.load(99).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[99].should == {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.delete(99).should == {"hashval1"=>["array1", 1]}
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[99].should == {"hashval1"=>["array1", 1]}
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[99].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.fetch(99, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(170141183460469231731687303715884105728).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(170141183460469231731687303715884105728).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete(170141183460469231731687303715884105728).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(170141183460469231731687303715884105728, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(99).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store(99, value).should equal(value)
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load(99).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete(99).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99] = {"hashval1"=>["array1", 1]}
+ store[99].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[99] = value).should equal(value)
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(99, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_numberkey_hashvalue ####################
+
+shared_examples_for 'returndifferent_numberkey_hashvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_numberkey_hashvalue ####################
+
+shared_examples_for 'returnsame_numberkey_hashvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+end
+
+#################### persist_numberkey_hashvalue ####################
+
+shared_examples_for 'persist_numberkey_hashvalue' do
+ it 'persists values' do
+ store[0.5] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store[0.5].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store[-0.3] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store[-0.3].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store[0.5] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store[0.5].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'persists values' do
+ store[-0.3] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store[-0.3].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store[99] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store[99].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'persists values' do
+ store[99] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store[99].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+end
+
+#################### null_numberkey_objectvalue ####################
+
+shared_examples_for 'null_numberkey_objectvalue' do
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = Value.new(:objval1)
+ store[-0.3] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = Value.new(:objval1)
+ store[0.5] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[0.5].should be_nil
+ store.load(0.5).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store[0.5] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(0.5).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(0.5).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[0.5] = Value.new(:objval2)
+ store[-0.3] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?(0.5).should be_false
+ store.key?(-0.3).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(0.5, Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 0.5
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(0.5, options).should be_false
+ store.load(0.5, options).should be_nil
+ store.fetch(0.5, 42, options).should == 42
+ store.fetch(0.5, options) { 42 }.should == 42
+ store.delete(0.5, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(0.5, Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[-0.3].should be_nil
+ store.load(-0.3).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store[-0.3] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(-0.3).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(-0.3).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[-0.3] = Value.new(:objval2)
+ store[0.5] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?(-0.3).should be_false
+ store.key?(0.5).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(-0.3, Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = -0.3
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(-0.3, options).should be_false
+ store.load(-0.3, options).should be_nil
+ store.fetch(-0.3, 42, options).should == 42
+ store.fetch(-0.3, options) { 42 }.should == 42
+ store.delete(-0.3, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(-0.3, Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[99] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[170141183460469231731687303715884105728].should be_nil
+ store.load(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(170141183460469231731687303715884105728).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[99] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ store.key?(99).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(170141183460469231731687303715884105728, Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 170141183460469231731687303715884105728
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(170141183460469231731687303715884105728, options).should be_false
+ store.load(170141183460469231731687303715884105728, options).should be_nil
+ store.fetch(170141183460469231731687303715884105728, 42, options).should == 42
+ store.fetch(170141183460469231731687303715884105728, options) { 42 }.should == 42
+ store.delete(170141183460469231731687303715884105728, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(170141183460469231731687303715884105728, Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+
+ it 'reads from keys like a Hash' do
+ store[99].should be_nil
+ store.load(99).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store[99] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(99).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(99).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[99] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?(99).should be_false
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(99, Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = 99
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(99, options).should be_false
+ store.load(99, options).should be_nil
+ store.fetch(99, 42, options).should == 42
+ store.fetch(99, options) { 42 }.should == 42
+ store.delete(99, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(99, Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+end
+
+#################### store_numberkey_objectvalue ####################
+
+shared_examples_for 'store_numberkey_objectvalue' do
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = Value.new(:objval1)
+ store[0.5].should == Value.new(:objval1)
+ store.load(0.5).should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = Value.new(:objval1)
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == Value.new(:objval1)
+ store.load(0.5).should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = Value.new(:objval1)
+ store[-0.3] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store[0.5] = Value.new(:objval1)
+ store[0.5].should == Value.new(:objval1)
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = Value.new(:objval1)
+ store.delete(0.5).should == Value.new(:objval1)
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = Value.new(:objval1)
+ store[0.5].should == Value.new(:objval1)
+ store[0.5] = Value.new(:objval2)
+ store[0.5].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = Value.new(:objval1)
+ store[0.5].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = Value.new(:objval1)
+ store.fetch(0.5, Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = Value.new(:objval1)
+ store[-0.3].should == Value.new(:objval1)
+ store.load(-0.3).should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = Value.new(:objval1)
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == Value.new(:objval1)
+ store.load(-0.3).should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = Value.new(:objval1)
+ store[0.5] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store[-0.3] = Value.new(:objval1)
+ store[-0.3].should == Value.new(:objval1)
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = Value.new(:objval1)
+ store.delete(-0.3).should == Value.new(:objval1)
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = Value.new(:objval1)
+ store[-0.3].should == Value.new(:objval1)
+ store[-0.3] = Value.new(:objval2)
+ store[-0.3].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = Value.new(:objval1)
+ store[-0.3].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = Value.new(:objval1)
+ store.fetch(-0.3, Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[0.5] = Value.new(:objval2)
+ store[0.5].should == Value.new(:objval2)
+ store.load(0.5).should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[0.5] = Value.new(:objval2)
+ store.key?(0.5).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store(0.5, value).should equal(value)
+ store[0.5].should == Value.new(:objval2)
+ store.load(0.5).should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store[0.5] = Value.new(:objval2)
+ store[-0.3] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store[0.5] = Value.new(:objval2)
+ store[0.5].should == Value.new(:objval2)
+ store[-0.3].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[0.5] = Value.new(:objval2)
+ store.delete(0.5).should == Value.new(:objval2)
+ store.key?(0.5).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[0.5] = Value.new(:objval2)
+ store[0.5].should == Value.new(:objval2)
+ store[0.5] = Value.new(:objval1)
+ store[0.5].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[0.5] = value).should equal(value)
+ store[0.5].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = 0.5.freeze
+ store[key] = Value.new(:objval2)
+ store[0.5].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[0.5] = Value.new(:objval2)
+ store.fetch(0.5, Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[0.5] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch(0.5) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[-0.3] = Value.new(:objval2)
+ store[-0.3].should == Value.new(:objval2)
+ store.load(-0.3).should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[-0.3] = Value.new(:objval2)
+ store.key?(-0.3).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store(-0.3, value).should equal(value)
+ store[-0.3].should == Value.new(:objval2)
+ store.load(-0.3).should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store[-0.3] = Value.new(:objval2)
+ store[0.5] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store[-0.3] = Value.new(:objval2)
+ store[-0.3].should == Value.new(:objval2)
+ store[0.5].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[-0.3] = Value.new(:objval2)
+ store.delete(-0.3).should == Value.new(:objval2)
+ store.key?(-0.3).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[-0.3] = Value.new(:objval2)
+ store[-0.3].should == Value.new(:objval2)
+ store[-0.3] = Value.new(:objval1)
+ store[-0.3].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[-0.3] = value).should equal(value)
+ store[-0.3].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = -0.3.freeze
+ store[key] = Value.new(:objval2)
+ store[-0.3].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[-0.3] = Value.new(:objval2)
+ store.fetch(-0.3, Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[-0.3] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch(-0.3) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ store.load(170141183460469231731687303715884105728).should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ store.load(170141183460469231731687303715884105728).should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[99] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.delete(170141183460469231731687303715884105728).should == Value.new(:objval1)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.fetch(170141183460469231731687303715884105728, Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = Value.new(:objval1)
+ store[99].should == Value.new(:objval1)
+ store.load(99).should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = Value.new(:objval1)
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store(99, value).should equal(value)
+ store[99].should == Value.new(:objval1)
+ store.load(99).should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store[99] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store[99] = Value.new(:objval1)
+ store[99].should == Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = Value.new(:objval1)
+ store.delete(99).should == Value.new(:objval1)
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = Value.new(:objval1)
+ store[99].should == Value.new(:objval1)
+ store[99] = Value.new(:objval2)
+ store[99].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[99] = value).should equal(value)
+ store[99].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = Value.new(:objval1)
+ store[99].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = Value.new(:objval1)
+ store.fetch(99, Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ store.load(170141183460469231731687303715884105728).should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.key?(170141183460469231731687303715884105728).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store(170141183460469231731687303715884105728, value).should equal(value)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ store.load(170141183460469231731687303715884105728).should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[99] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ store[99].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.delete(170141183460469231731687303715884105728).should == Value.new(:objval2)
+ store.key?(170141183460469231731687303715884105728).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[170141183460469231731687303715884105728] = value).should equal(value)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = 170141183460469231731687303715884105728.freeze
+ store[key] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.fetch(170141183460469231731687303715884105728, Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch(170141183460469231731687303715884105728) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[99] = Value.new(:objval2)
+ store[99].should == Value.new(:objval2)
+ store.load(99).should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[99] = Value.new(:objval2)
+ store.key?(99).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store(99, value).should equal(value)
+ store[99].should == Value.new(:objval2)
+ store.load(99).should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store[99] = Value.new(:objval2)
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store[99] = Value.new(:objval2)
+ store[99].should == Value.new(:objval2)
+ store[170141183460469231731687303715884105728].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[99] = Value.new(:objval2)
+ store.delete(99).should == Value.new(:objval2)
+ store.key?(99).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[99] = Value.new(:objval2)
+ store[99].should == Value.new(:objval2)
+ store[99] = Value.new(:objval1)
+ store[99].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[99] = value).should equal(value)
+ store[99].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = 99.freeze
+ store[key] = Value.new(:objval2)
+ store[99].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[99] = Value.new(:objval2)
+ store.fetch(99, Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[99] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch(99) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_numberkey_objectvalue ####################
+
+shared_examples_for 'returndifferent_numberkey_objectvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store[0.5] = value
+ store[0.5].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store[-0.3] = value
+ store[-0.3].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store[99] = value
+ store[99].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_numberkey_objectvalue ####################
+
+shared_examples_for 'returnsame_numberkey_objectvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store[0.5] = value
+ store[0.5].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store[-0.3] = value
+ store[-0.3].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store[170141183460469231731687303715884105728] = value
+ store[170141183460469231731687303715884105728].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store[99] = value
+ store[99].should be_equal(value)
+ end
+end
+
+#################### persist_numberkey_objectvalue ####################
+
+shared_examples_for 'persist_numberkey_objectvalue' do
+ it 'persists values' do
+ store[0.5] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store[0.5].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store[-0.3] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store[-0.3].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store[0.5] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store[0.5].should == Value.new(:objval2)
+ end
+
+ it 'persists values' do
+ store[-0.3] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store[-0.3].should == Value.new(:objval2)
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store[99] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store[99].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store[170141183460469231731687303715884105728] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store[170141183460469231731687303715884105728].should == Value.new(:objval2)
+ end
+
+ it 'persists values' do
+ store[99] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store[99].should == Value.new(:objval2)
+ end
+end
+
#################### null_booleankey_nilvalue ####################
shared_examples_for 'null_booleankey_nilvalue' do
it 'reads from keys like a Hash' do
store[true].should be_nil
@@ -5873,10 +16461,22 @@
store[true].should == 0
store[true] = nil
store[true].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = 0
+ store[true].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[false] = 0
store[false].should == 0
store.load(false).should == 0
end
@@ -5913,10 +16513,22 @@
store[false].should == 0
store[false] = nil
store[false].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = 0
+ store[false].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[true] = nil
store[true].should == nil
store.load(true).should == nil
end
@@ -5953,10 +16565,22 @@
store[true].should == nil
store[true] = 0
store[true].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = nil
+ store[true].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store[false] = nil
store[false].should == nil
store.load(false).should == nil
end
@@ -5992,10 +16616,22 @@
store[false] = nil
store[false].should == nil
store[false] = 0
store[false].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = nil
+ store[false].should == nil
+ end
end
#################### persist_booleankey_nilvalue ####################
shared_examples_for 'persist_booleankey_nilvalue' do
@@ -6276,10 +16912,22 @@
store[true] = 41
store[true].should == 41
store[true] = -12
store[true].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = 41
+ store[true].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = 41
store.fetch(true, -12).should == 41
end
@@ -6327,10 +16975,22 @@
store[false] = 41
store[false].should == 41
store[false] = -12
store[false].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = 41
+ store[false].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = 41
store.fetch(false, -12).should == 41
end
@@ -6378,10 +17038,22 @@
store[true] = -12
store[true].should == -12
store[true] = 41
store[true].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = -12
+ store[true].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = -12
store.fetch(true, 41).should == -12
end
@@ -6429,10 +17101,22 @@
store[false] = -12
store[false].should == -12
store[false] = 41
store[false].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = -12
+ store[false].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = -12
store.fetch(false, 41).should == -12
end
@@ -6474,10 +17158,990 @@
@store = nil
store[false].should == -12
end
end
+#################### null_booleankey_numbervalue ####################
+
+shared_examples_for 'null_booleankey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[true].should be_nil
+ store.load(true).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[true] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(true).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(true).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[true] = 123.456
+ store[false] = -98.7
+ store.clear.should equal(store)
+ store.key?(true).should be_false
+ store.key?(false).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(true, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = true
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(true, options).should be_false
+ store.load(true, options).should be_nil
+ store.fetch(true, 42, options).should == 42
+ store.fetch(true, options) { 42 }.should == 42
+ store.delete(true, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(true, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[false].should be_nil
+ store.load(false).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[false] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(false).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(false).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[false] = 123.456
+ store[true] = -98.7
+ store.clear.should equal(store)
+ store.key?(false).should be_false
+ store.key?(true).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(false, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = false
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(false, options).should be_false
+ store.load(false, options).should be_nil
+ store.fetch(false, 42, options).should == 42
+ store.fetch(false, options) { 42 }.should == 42
+ store.delete(false, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(false, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[true].should be_nil
+ store.load(true).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[true] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(true).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(true).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[true] = -98.7
+ store[false] = 123.456
+ store.clear.should equal(store)
+ store.key?(true).should be_false
+ store.key?(false).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(true, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = true
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(true, options).should be_false
+ store.load(true, options).should be_nil
+ store.fetch(true, 42, options).should == 42
+ store.fetch(true, options) { 42 }.should == 42
+ store.delete(true, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(true, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[false].should be_nil
+ store.load(false).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[false] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(false).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(false).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[false] = -98.7
+ store[true] = 123.456
+ store.clear.should equal(store)
+ store.key?(false).should be_false
+ store.key?(true).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(false, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = false
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(false, options).should be_false
+ store.load(false, options).should be_nil
+ store.fetch(false, 42, options).should == 42
+ store.fetch(false, options) { 42 }.should == 42
+ store.delete(false, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(false, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[true].should be_nil
+ store.load(true).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[true] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(true).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(true).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[true] = 340282366920938463463374607431768211456
+ store[false] = 33
+ store.clear.should equal(store)
+ store.key?(true).should be_false
+ store.key?(false).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(true, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = true
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(true, options).should be_false
+ store.load(true, options).should be_nil
+ store.fetch(true, 42, options).should == 42
+ store.fetch(true, options) { 42 }.should == 42
+ store.delete(true, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(true, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[false].should be_nil
+ store.load(false).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[false] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(false).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(false).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[false] = 340282366920938463463374607431768211456
+ store[true] = 33
+ store.clear.should equal(store)
+ store.key?(false).should be_false
+ store.key?(true).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(false, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = false
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(false, options).should be_false
+ store.load(false, options).should be_nil
+ store.fetch(false, 42, options).should == 42
+ store.fetch(false, options) { 42 }.should == 42
+ store.delete(false, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(false, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[true].should be_nil
+ store.load(true).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[true] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(true).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(true).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[true] = 33
+ store[false] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(true).should be_false
+ store.key?(false).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(true, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = true
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(true, options).should be_false
+ store.load(true, options).should be_nil
+ store.fetch(true, 42, options).should == 42
+ store.fetch(true, options) { 42 }.should == 42
+ store.delete(true, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(true, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[false].should be_nil
+ store.load(false).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[false] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(false).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(false).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[false] = 33
+ store[true] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(false).should be_false
+ store.key?(true).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(false, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = false
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(false, options).should be_false
+ store.load(false, options).should be_nil
+ store.fetch(false, 42, options).should == 42
+ store.fetch(false, options) { 42 }.should == 42
+ store.delete(false, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(false, 33, options).should == 33
+ end
+end
+
+#################### store_booleankey_numbervalue ####################
+
+shared_examples_for 'store_booleankey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[true] = 123.456
+ store[true].should == 123.456
+ store.load(true).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[true] = 123.456
+ store.key?(true).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(true, value).should equal(value)
+ store[true].should == 123.456
+ store.load(true).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[true] = 123.456
+ store[false] = -98.7
+ store.clear.should equal(store)
+ store[true] = 123.456
+ store[true].should == 123.456
+ store[false].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[true] = 123.456
+ store.delete(true).should == 123.456
+ store.key?(true).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[true] = 123.456
+ store[true].should == 123.456
+ store[true] = -98.7
+ store[true].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = 123.456
+ store[true].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[true] = 123.456
+ store.fetch(true, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[true] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(true) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[false] = 123.456
+ store[false].should == 123.456
+ store.load(false).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[false] = 123.456
+ store.key?(false).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(false, value).should equal(value)
+ store[false].should == 123.456
+ store.load(false).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[false] = 123.456
+ store[true] = -98.7
+ store.clear.should equal(store)
+ store[false] = 123.456
+ store[false].should == 123.456
+ store[true].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[false] = 123.456
+ store.delete(false).should == 123.456
+ store.key?(false).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[false] = 123.456
+ store[false].should == 123.456
+ store[false] = -98.7
+ store[false].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = 123.456
+ store[false].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[false] = 123.456
+ store.fetch(false, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[false] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(false) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[true] = -98.7
+ store[true].should == -98.7
+ store.load(true).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[true] = -98.7
+ store.key?(true).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(true, value).should equal(value)
+ store[true].should == -98.7
+ store.load(true).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[true] = -98.7
+ store[false] = 123.456
+ store.clear.should equal(store)
+ store[true] = -98.7
+ store[true].should == -98.7
+ store[false].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[true] = -98.7
+ store.delete(true).should == -98.7
+ store.key?(true).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[true] = -98.7
+ store[true].should == -98.7
+ store[true] = 123.456
+ store[true].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = -98.7
+ store[true].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[true] = -98.7
+ store.fetch(true, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[true] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(true) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[false] = -98.7
+ store[false].should == -98.7
+ store.load(false).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[false] = -98.7
+ store.key?(false).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(false, value).should equal(value)
+ store[false].should == -98.7
+ store.load(false).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[false] = -98.7
+ store[true] = 123.456
+ store.clear.should equal(store)
+ store[false] = -98.7
+ store[false].should == -98.7
+ store[true].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[false] = -98.7
+ store.delete(false).should == -98.7
+ store.key?(false).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[false] = -98.7
+ store[false].should == -98.7
+ store[false] = 123.456
+ store[false].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = -98.7
+ store[false].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[false] = -98.7
+ store.fetch(false, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[false] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(false) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[true] = 340282366920938463463374607431768211456
+ store[true].should == 340282366920938463463374607431768211456
+ store.load(true).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[true] = 340282366920938463463374607431768211456
+ store.key?(true).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(true, value).should equal(value)
+ store[true].should == 340282366920938463463374607431768211456
+ store.load(true).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[true] = 340282366920938463463374607431768211456
+ store[false] = 33
+ store.clear.should equal(store)
+ store[true] = 340282366920938463463374607431768211456
+ store[true].should == 340282366920938463463374607431768211456
+ store[false].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[true] = 340282366920938463463374607431768211456
+ store.delete(true).should == 340282366920938463463374607431768211456
+ store.key?(true).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[true] = 340282366920938463463374607431768211456
+ store[true].should == 340282366920938463463374607431768211456
+ store[true] = 33
+ store[true].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[true].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[true] = 340282366920938463463374607431768211456
+ store.fetch(true, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[true] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(true) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[false] = 340282366920938463463374607431768211456
+ store[false].should == 340282366920938463463374607431768211456
+ store.load(false).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[false] = 340282366920938463463374607431768211456
+ store.key?(false).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(false, value).should equal(value)
+ store[false].should == 340282366920938463463374607431768211456
+ store.load(false).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[false] = 340282366920938463463374607431768211456
+ store[true] = 33
+ store.clear.should equal(store)
+ store[false] = 340282366920938463463374607431768211456
+ store[false].should == 340282366920938463463374607431768211456
+ store[true].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[false] = 340282366920938463463374607431768211456
+ store.delete(false).should == 340282366920938463463374607431768211456
+ store.key?(false).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[false] = 340282366920938463463374607431768211456
+ store[false].should == 340282366920938463463374607431768211456
+ store[false] = 33
+ store[false].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[false].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[false] = 340282366920938463463374607431768211456
+ store.fetch(false, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[false] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(false) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[true] = 33
+ store[true].should == 33
+ store.load(true).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[true] = 33
+ store.key?(true).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(true, value).should equal(value)
+ store[true].should == 33
+ store.load(true).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[true] = 33
+ store[false] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[true] = 33
+ store[true].should == 33
+ store[false].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[true] = 33
+ store.delete(true).should == 33
+ store.key?(true).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[true] = 33
+ store[true].should == 33
+ store[true] = 340282366920938463463374607431768211456
+ store[true].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = 33
+ store[true].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[true] = 33
+ store.fetch(true, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[true] = 33
+ unaltered = 'unaltered'
+ store.fetch(true) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[false] = 33
+ store[false].should == 33
+ store.load(false).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[false] = 33
+ store.key?(false).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(false, value).should equal(value)
+ store[false].should == 33
+ store.load(false).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[false] = 33
+ store[true] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[false] = 33
+ store[false].should == 33
+ store[true].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[false] = 33
+ store.delete(false).should == 33
+ store.key?(false).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[false] = 33
+ store[false].should == 33
+ store[false] = 340282366920938463463374607431768211456
+ store[false].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = 33
+ store[false].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[false] = 33
+ store.fetch(false, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[false] = 33
+ unaltered = 'unaltered'
+ store.fetch(false) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_booleankey_numbervalue ####################
+
+shared_examples_for 'persist_booleankey_numbervalue' do
+ it 'persists values' do
+ store[true] = 123.456
+ store.close
+ @store = nil
+ store[true].should == 123.456
+ end
+
+ it 'persists values' do
+ store[false] = 123.456
+ store.close
+ @store = nil
+ store[false].should == 123.456
+ end
+
+ it 'persists values' do
+ store[true] = -98.7
+ store.close
+ @store = nil
+ store[true].should == -98.7
+ end
+
+ it 'persists values' do
+ store[false] = -98.7
+ store.close
+ @store = nil
+ store[false].should == -98.7
+ end
+
+ it 'persists values' do
+ store[true] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[true].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[false] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[false].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[true] = 33
+ store.close
+ @store = nil
+ store[true].should == 33
+ end
+
+ it 'persists values' do
+ store[false] = 33
+ store.close
+ @store = nil
+ store[false].should == 33
+ end
+end
+
#################### null_booleankey_booleanvalue ####################
shared_examples_for 'null_booleankey_booleanvalue' do
it 'reads from keys like a Hash' do
store[true].should be_nil
@@ -6724,10 +18388,22 @@
store[true] = true
store[true].should == true
store[true] = false
store[true].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = true
+ store[true].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = true
store.fetch(true, false).should == true
end
@@ -6775,10 +18451,22 @@
store[false] = true
store[false].should == true
store[false] = false
store[false].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = true
+ store[false].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = true
store.fetch(false, false).should == true
end
@@ -6826,10 +18514,22 @@
store[true] = false
store[true].should == false
store[true] = true
store[true].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = false
+ store[true].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = false
store.fetch(true, true).should == false
end
@@ -6877,10 +18577,22 @@
store[false] = false
store[false].should == false
store[false] = true
store[false].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = false
+ store[false].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = false
store.fetch(false, true).should == false
end
@@ -7172,10 +18884,22 @@
store[true] = "strval1"
store[true].should == "strval1"
store[true] = "strval2"
store[true].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[true] = value).should equal(value)
+ store[true].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = "strval1"
+ store[true].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = "strval1"
store.fetch(true, "strval2").should == "strval1"
end
@@ -7223,10 +18947,22 @@
store[false] = "strval1"
store[false].should == "strval1"
store[false] = "strval2"
store[false].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[false] = value).should equal(value)
+ store[false].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = "strval1"
+ store[false].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = "strval1"
store.fetch(false, "strval2").should == "strval1"
end
@@ -7274,10 +19010,22 @@
store[true] = "strval2"
store[true].should == "strval2"
store[true] = "strval1"
store[true].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[true] = value).should equal(value)
+ store[true].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = "strval2"
+ store[true].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = "strval2"
store.fetch(true, "strval1").should == "strval2"
end
@@ -7325,10 +19073,22 @@
store[false] = "strval2"
store[false].should == "strval2"
store[false] = "strval1"
store[false].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[false] = value).should equal(value)
+ store[false].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = "strval2"
+ store[false].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = "strval2"
store.fetch(false, "strval1").should == "strval2"
end
@@ -7676,10 +19436,22 @@
store[true] = {"hashval1"=>["array1", 1]}
store[true].should == {"hashval1"=>["array1", 1]}
store[true] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[true].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[true].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = {"hashval1"=>["array1", 1]}
store.fetch(true, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -7727,10 +19499,22 @@
store[false] = {"hashval1"=>["array1", 1]}
store[false].should == {"hashval1"=>["array1", 1]}
store[false] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[false].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[false].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = {"hashval1"=>["array1", 1]}
store.fetch(false, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -7778,10 +19562,22 @@
store[true] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[true].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[true] = {"hashval1"=>["array1", 1]}
store[true].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[true] = value).should equal(value)
+ store[true].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[true].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(true, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -7829,10 +19625,22 @@
store[false] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[false].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[false] = {"hashval1"=>["array1", 1]}
store[false].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[false] = value).should equal(value)
+ store[false].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[false].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(false, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -8180,10 +19988,22 @@
store[true] = Value.new(:objval1)
store[true].should == Value.new(:objval1)
store[true] = Value.new(:objval2)
store[true].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[true] = value).should equal(value)
+ store[true].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = Value.new(:objval1)
+ store[true].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = Value.new(:objval1)
store.fetch(true, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -8231,10 +20051,22 @@
store[false] = Value.new(:objval1)
store[false].should == Value.new(:objval1)
store[false] = Value.new(:objval2)
store[false].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[false] = value).should equal(value)
+ store[false].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = Value.new(:objval1)
+ store[false].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = Value.new(:objval1)
store.fetch(false, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -8282,10 +20114,22 @@
store[true] = Value.new(:objval2)
store[true].should == Value.new(:objval2)
store[true] = Value.new(:objval1)
store[true].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[true] = value).should equal(value)
+ store[true].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = true.freeze
+ store[key] = Value.new(:objval2)
+ store[true].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[true] = Value.new(:objval2)
store.fetch(true, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -8333,10 +20177,22 @@
store[false] = Value.new(:objval2)
store[false].should == Value.new(:objval2)
store[false] = Value.new(:objval1)
store[false].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[false] = value).should equal(value)
+ store[false].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = false.freeze
+ store[key] = Value.new(:objval2)
+ store[false].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[false] = Value.new(:objval2)
store.fetch(false, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -8640,10 +20496,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", nil, options).should == nil
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = 0
+ store["bar/foo/baz"] = nil
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = 0
+ store["foo/bar"] = nil
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = nil
+ store["bar/foo/baz"] = 0
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", nil, options).should == nil
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = nil
+ store["foo/bar"] = 0
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", nil, options).should == nil
+ end
end
#################### store_stringkey_nilvalue ####################
shared_examples_for 'store_stringkey_nilvalue' do
@@ -8685,10 +20745,22 @@
store["strkey1"].should == 0
store["strkey1"] = nil
store["strkey1"].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 0
+ store["strkey1"].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store["strkey2"] = 0
store["strkey2"].should == 0
store.load("strkey2").should == 0
end
@@ -8725,10 +20797,22 @@
store["strkey2"].should == 0
store["strkey2"] = nil
store["strkey2"].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 0
+ store["strkey2"].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store["strkey1"] = nil
store["strkey1"].should == nil
store.load("strkey1").should == nil
end
@@ -8765,10 +20849,22 @@
store["strkey1"].should == nil
store["strkey1"] = 0
store["strkey1"].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = nil
+ store["strkey1"].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store["strkey2"] = nil
store["strkey2"].should == nil
store.load("strkey2").should == nil
end
@@ -8804,10 +20900,230 @@
store["strkey2"] = nil
store["strkey2"].should == nil
store["strkey2"] = 0
store["strkey2"].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = nil
+ store["strkey2"].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = 0
+ store["foo/bar"].should == 0
+ store.load("foo/bar").should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = 0
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == 0
+ store.load("foo/bar").should == 0
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = 0
+ store["bar/foo/baz"] = nil
+ store.clear.should equal(store)
+ store["foo/bar"] = 0
+ store["foo/bar"].should == 0
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = 0
+ store.delete("foo/bar").should == 0
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = 0
+ store["foo/bar"].should == 0
+ store["foo/bar"] = nil
+ store["foo/bar"].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = 0
+ store["foo/bar"].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = 0
+ store["bar/foo/baz"].should == 0
+ store.load("bar/foo/baz").should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = 0
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == 0
+ store.load("bar/foo/baz").should == 0
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = 0
+ store["foo/bar"] = nil
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = 0
+ store["bar/foo/baz"].should == 0
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = 0
+ store.delete("bar/foo/baz").should == 0
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = 0
+ store["bar/foo/baz"].should == 0
+ store["bar/foo/baz"] = nil
+ store["bar/foo/baz"].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = 0
+ store["bar/foo/baz"].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = nil
+ store["foo/bar"].should == nil
+ store.load("foo/bar").should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = nil
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == nil
+ store.load("foo/bar").should == nil
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = nil
+ store["bar/foo/baz"] = 0
+ store.clear.should equal(store)
+ store["foo/bar"] = nil
+ store["foo/bar"].should == nil
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = nil
+ store.delete("foo/bar").should == nil
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = nil
+ store["foo/bar"].should == nil
+ store["foo/bar"] = 0
+ store["foo/bar"].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = nil
+ store["foo/bar"].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = nil
+ store["bar/foo/baz"].should == nil
+ store.load("bar/foo/baz").should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = nil
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == nil
+ store.load("bar/foo/baz").should == nil
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = nil
+ store["foo/bar"] = 0
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = nil
+ store["bar/foo/baz"].should == nil
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = nil
+ store.delete("bar/foo/baz").should == nil
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = nil
+ store["bar/foo/baz"].should == nil
+ store["bar/foo/baz"] = 0
+ store["bar/foo/baz"].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = nil
+ store["bar/foo/baz"].should == nil
+ end
end
#################### persist_stringkey_nilvalue ####################
shared_examples_for 'persist_stringkey_nilvalue' do
@@ -8836,10 +21152,38 @@
store["strkey2"] = nil
store.close
@store = nil
store["strkey2"].should == nil
end
+
+ it 'persists values' do
+ store["foo/bar"] = 0
+ store.close
+ @store = nil
+ store["foo/bar"].should == 0
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = 0
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == 0
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = nil
+ store.close
+ @store = nil
+ store["foo/bar"].should == nil
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = nil
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == nil
+ end
end
#################### null_stringkey_integervalue ####################
shared_examples_for 'null_stringkey_integervalue' do
@@ -9044,10 +21388,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", -12, options).should == -12
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = 41
+ store["bar/foo/baz"] = -12
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = 41
+ store["foo/bar"] = -12
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = -12
+ store["bar/foo/baz"] = 41
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", -12, options).should == -12
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = -12
+ store["foo/bar"] = 41
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", -12, options).should == -12
+ end
end
#################### store_stringkey_integervalue ####################
shared_examples_for 'store_stringkey_integervalue' do
@@ -9088,10 +21636,22 @@
store["strkey1"] = 41
store["strkey1"].should == 41
store["strkey1"] = -12
store["strkey1"].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 41
+ store["strkey1"].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = 41
store.fetch("strkey1", -12).should == 41
end
@@ -9139,10 +21699,22 @@
store["strkey2"] = 41
store["strkey2"].should == 41
store["strkey2"] = -12
store["strkey2"].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 41
+ store["strkey2"].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = 41
store.fetch("strkey2", -12).should == 41
end
@@ -9190,10 +21762,22 @@
store["strkey1"] = -12
store["strkey1"].should == -12
store["strkey1"] = 41
store["strkey1"].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = -12
+ store["strkey1"].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = -12
store.fetch("strkey1", 41).should == -12
end
@@ -9241,10 +21825,22 @@
store["strkey2"] = -12
store["strkey2"].should == -12
store["strkey2"] = 41
store["strkey2"].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = -12
+ store["strkey2"].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = -12
store.fetch("strkey2", 41).should == -12
end
@@ -9252,10 +21848,262 @@
store["strkey2"] = -12
unaltered = 'unaltered'
store.fetch("strkey2") { unaltered = 'altered' }
unaltered.should == 'unaltered'
end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = 41
+ store["foo/bar"].should == 41
+ store.load("foo/bar").should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = 41
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == 41
+ store.load("foo/bar").should == 41
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = 41
+ store["bar/foo/baz"] = -12
+ store.clear.should equal(store)
+ store["foo/bar"] = 41
+ store["foo/bar"].should == 41
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = 41
+ store.delete("foo/bar").should == 41
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = 41
+ store["foo/bar"].should == 41
+ store["foo/bar"] = -12
+ store["foo/bar"].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = 41
+ store["foo/bar"].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = 41
+ store.fetch("foo/bar", -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = 41
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = 41
+ store["bar/foo/baz"].should == 41
+ store.load("bar/foo/baz").should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = 41
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == 41
+ store.load("bar/foo/baz").should == 41
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = 41
+ store["foo/bar"] = -12
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = 41
+ store["bar/foo/baz"].should == 41
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = 41
+ store.delete("bar/foo/baz").should == 41
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = 41
+ store["bar/foo/baz"].should == 41
+ store["bar/foo/baz"] = -12
+ store["bar/foo/baz"].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = 41
+ store["bar/foo/baz"].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = 41
+ store.fetch("bar/foo/baz", -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = 41
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = -12
+ store["foo/bar"].should == -12
+ store.load("foo/bar").should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = -12
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == -12
+ store.load("foo/bar").should == -12
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = -12
+ store["bar/foo/baz"] = 41
+ store.clear.should equal(store)
+ store["foo/bar"] = -12
+ store["foo/bar"].should == -12
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = -12
+ store.delete("foo/bar").should == -12
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = -12
+ store["foo/bar"].should == -12
+ store["foo/bar"] = 41
+ store["foo/bar"].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = -12
+ store["foo/bar"].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = -12
+ store.fetch("foo/bar", 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = -12
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = -12
+ store["bar/foo/baz"].should == -12
+ store.load("bar/foo/baz").should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = -12
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == -12
+ store.load("bar/foo/baz").should == -12
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = -12
+ store["foo/bar"] = 41
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = -12
+ store["bar/foo/baz"].should == -12
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = -12
+ store.delete("bar/foo/baz").should == -12
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = -12
+ store["bar/foo/baz"].should == -12
+ store["bar/foo/baz"] = 41
+ store["bar/foo/baz"].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = -12
+ store["bar/foo/baz"].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = -12
+ store.fetch("bar/foo/baz", 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = -12
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
end
#################### persist_stringkey_integervalue ####################
shared_examples_for 'persist_stringkey_integervalue' do
@@ -9284,12 +22132,1988 @@
store["strkey2"] = -12
store.close
@store = nil
store["strkey2"].should == -12
end
+
+ it 'persists values' do
+ store["foo/bar"] = 41
+ store.close
+ @store = nil
+ store["foo/bar"].should == 41
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = 41
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == 41
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = -12
+ store.close
+ @store = nil
+ store["foo/bar"].should == -12
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = -12
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == -12
+ end
end
+#################### null_stringkey_numbervalue ####################
+
+shared_examples_for 'null_stringkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 123.456
+ store["strkey2"] = -98.7
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 123.456
+ store["strkey1"] = -98.7
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = -98.7
+ store["strkey2"] = 123.456
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = -98.7
+ store["strkey1"] = 123.456
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = 123.456
+ store["bar/foo/baz"] = -98.7
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = 123.456
+ store["foo/bar"] = -98.7
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = -98.7
+ store["bar/foo/baz"] = 123.456
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = -98.7
+ store["foo/bar"] = 123.456
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"] = 33
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["foo/bar"] = 33
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = 33
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = 33
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", 33, options).should == 33
+ end
+end
+
+#################### store_stringkey_numbervalue ####################
+
+shared_examples_for 'store_stringkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store.load("strkey1").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 123.456
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 123.456
+ store.load("strkey1").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 123.456
+ store["strkey2"] = -98.7
+ store.clear.should equal(store)
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 123.456
+ store.delete("strkey1").should == 123.456
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 123.456
+ store["strkey1"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 123.456
+ store.fetch("strkey1", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store.load("strkey2").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 123.456
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 123.456
+ store.load("strkey2").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 123.456
+ store["strkey1"] = -98.7
+ store.clear.should equal(store)
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 123.456
+ store.delete("strkey2").should == 123.456
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 123.456
+ store["strkey2"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 123.456
+ store.fetch("strkey2", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store.load("strkey1").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = -98.7
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == -98.7
+ store.load("strkey1").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = -98.7
+ store["strkey2"] = 123.456
+ store.clear.should equal(store)
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = -98.7
+ store.delete("strkey1").should == -98.7
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = -98.7
+ store["strkey1"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = -98.7
+ store.fetch("strkey1", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store.load("strkey2").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = -98.7
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == -98.7
+ store.load("strkey2").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = -98.7
+ store["strkey1"] = 123.456
+ store.clear.should equal(store)
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = -98.7
+ store.delete("strkey2").should == -98.7
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = -98.7
+ store["strkey2"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = -98.7
+ store.fetch("strkey2", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store.load("strkey1").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store.load("strkey1").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store.clear.should equal(store)
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.delete("strkey1").should == 340282366920938463463374607431768211456
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.fetch("strkey1", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store.load("strkey2").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store.load("strkey2").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store.clear.should equal(store)
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.delete("strkey2").should == 340282366920938463463374607431768211456
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.fetch("strkey2", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store.load("strkey1").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 33
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 33
+ store.load("strkey1").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 33
+ store.delete("strkey1").should == 33
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 33
+ store["strkey1"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 33
+ store.fetch("strkey1", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 33
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store.load("strkey2").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 33
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 33
+ store.load("strkey2").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 33
+ store.delete("strkey2").should == 33
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 33
+ store["strkey2"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 33
+ store.fetch("strkey2", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 33
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = 123.456
+ store["foo/bar"].should == 123.456
+ store.load("foo/bar").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = 123.456
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == 123.456
+ store.load("foo/bar").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = 123.456
+ store["bar/foo/baz"] = -98.7
+ store.clear.should equal(store)
+ store["foo/bar"] = 123.456
+ store["foo/bar"].should == 123.456
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = 123.456
+ store.delete("foo/bar").should == 123.456
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = 123.456
+ store["foo/bar"].should == 123.456
+ store["foo/bar"] = -98.7
+ store["foo/bar"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = 123.456
+ store["foo/bar"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = 123.456
+ store.fetch("foo/bar", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = 123.456
+ store["bar/foo/baz"].should == 123.456
+ store.load("bar/foo/baz").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = 123.456
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == 123.456
+ store.load("bar/foo/baz").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = 123.456
+ store["foo/bar"] = -98.7
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = 123.456
+ store["bar/foo/baz"].should == 123.456
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = 123.456
+ store.delete("bar/foo/baz").should == 123.456
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = 123.456
+ store["bar/foo/baz"].should == 123.456
+ store["bar/foo/baz"] = -98.7
+ store["bar/foo/baz"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = 123.456
+ store["bar/foo/baz"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = 123.456
+ store.fetch("bar/foo/baz", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = -98.7
+ store["foo/bar"].should == -98.7
+ store.load("foo/bar").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = -98.7
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == -98.7
+ store.load("foo/bar").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = -98.7
+ store["bar/foo/baz"] = 123.456
+ store.clear.should equal(store)
+ store["foo/bar"] = -98.7
+ store["foo/bar"].should == -98.7
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = -98.7
+ store.delete("foo/bar").should == -98.7
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = -98.7
+ store["foo/bar"].should == -98.7
+ store["foo/bar"] = 123.456
+ store["foo/bar"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = -98.7
+ store["foo/bar"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = -98.7
+ store.fetch("foo/bar", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = -98.7
+ store["bar/foo/baz"].should == -98.7
+ store.load("bar/foo/baz").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = -98.7
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == -98.7
+ store.load("bar/foo/baz").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = -98.7
+ store["foo/bar"] = 123.456
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = -98.7
+ store["bar/foo/baz"].should == -98.7
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = -98.7
+ store.delete("bar/foo/baz").should == -98.7
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = -98.7
+ store["bar/foo/baz"].should == -98.7
+ store["bar/foo/baz"] = 123.456
+ store["bar/foo/baz"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = -98.7
+ store["bar/foo/baz"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = -98.7
+ store.fetch("bar/foo/baz", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ store.load("foo/bar").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ store.load("foo/bar").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"] = 33
+ store.clear.should equal(store)
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.delete("foo/bar").should == 340282366920938463463374607431768211456
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ store["foo/bar"] = 33
+ store["foo/bar"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.fetch("foo/bar", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ store.load("bar/foo/baz").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ store.load("bar/foo/baz").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["foo/bar"] = 33
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.delete("bar/foo/baz").should == 340282366920938463463374607431768211456
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ store["bar/foo/baz"] = 33
+ store["bar/foo/baz"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.fetch("bar/foo/baz", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = 33
+ store["foo/bar"].should == 33
+ store.load("foo/bar").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = 33
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == 33
+ store.load("foo/bar").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = 33
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["foo/bar"] = 33
+ store["foo/bar"].should == 33
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = 33
+ store.delete("foo/bar").should == 33
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = 33
+ store["foo/bar"].should == 33
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = 33
+ store["foo/bar"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = 33
+ store.fetch("foo/bar", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = 33
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = 33
+ store["bar/foo/baz"].should == 33
+ store.load("bar/foo/baz").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = 33
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == 33
+ store.load("bar/foo/baz").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = 33
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = 33
+ store["bar/foo/baz"].should == 33
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = 33
+ store.delete("bar/foo/baz").should == 33
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = 33
+ store["bar/foo/baz"].should == 33
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = 33
+ store["bar/foo/baz"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = 33
+ store.fetch("bar/foo/baz", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = 33
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_stringkey_numbervalue ####################
+
+shared_examples_for 'persist_stringkey_numbervalue' do
+ it 'persists values' do
+ store["strkey1"] = 123.456
+ store.close
+ @store = nil
+ store["strkey1"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 123.456
+ store.close
+ @store = nil
+ store["strkey2"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["strkey1"] = -98.7
+ store.close
+ @store = nil
+ store["strkey1"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["strkey2"] = -98.7
+ store.close
+ @store = nil
+ store["strkey2"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["strkey1"] = 33
+ store.close
+ @store = nil
+ store["strkey1"].should == 33
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 33
+ store.close
+ @store = nil
+ store["strkey2"].should == 33
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = 123.456
+ store.close
+ @store = nil
+ store["foo/bar"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = 123.456
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = -98.7
+ store.close
+ @store = nil
+ store["foo/bar"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = -98.7
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["foo/bar"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = 33
+ store.close
+ @store = nil
+ store["foo/bar"].should == 33
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = 33
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == 33
+ end
+end
+
#################### null_stringkey_booleanvalue ####################
shared_examples_for 'null_stringkey_booleanvalue' do
it 'reads from keys like a Hash' do
store["strkey1"].should be_nil
@@ -9492,10 +24316,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", false, options).should == false
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = true
+ store["bar/foo/baz"] = false
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = true
+ store["foo/bar"] = false
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = false
+ store["bar/foo/baz"] = true
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", false, options).should == false
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = false
+ store["foo/bar"] = true
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", false, options).should == false
+ end
end
#################### store_stringkey_booleanvalue ####################
shared_examples_for 'store_stringkey_booleanvalue' do
@@ -9536,10 +24564,22 @@
store["strkey1"] = true
store["strkey1"].should == true
store["strkey1"] = false
store["strkey1"].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = true
+ store["strkey1"].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = true
store.fetch("strkey1", false).should == true
end
@@ -9587,10 +24627,22 @@
store["strkey2"] = true
store["strkey2"].should == true
store["strkey2"] = false
store["strkey2"].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = true
+ store["strkey2"].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = true
store.fetch("strkey2", false).should == true
end
@@ -9638,10 +24690,22 @@
store["strkey1"] = false
store["strkey1"].should == false
store["strkey1"] = true
store["strkey1"].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = false
+ store["strkey1"].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = false
store.fetch("strkey1", true).should == false
end
@@ -9689,10 +24753,22 @@
store["strkey2"] = false
store["strkey2"].should == false
store["strkey2"] = true
store["strkey2"].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = false
+ store["strkey2"].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = false
store.fetch("strkey2", true).should == false
end
@@ -9700,10 +24776,262 @@
store["strkey2"] = false
unaltered = 'unaltered'
store.fetch("strkey2") { unaltered = 'altered' }
unaltered.should == 'unaltered'
end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = true
+ store["foo/bar"].should == true
+ store.load("foo/bar").should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = true
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == true
+ store.load("foo/bar").should == true
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = true
+ store["bar/foo/baz"] = false
+ store.clear.should equal(store)
+ store["foo/bar"] = true
+ store["foo/bar"].should == true
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = true
+ store.delete("foo/bar").should == true
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = true
+ store["foo/bar"].should == true
+ store["foo/bar"] = false
+ store["foo/bar"].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = true
+ store["foo/bar"].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = true
+ store.fetch("foo/bar", false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = true
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = true
+ store["bar/foo/baz"].should == true
+ store.load("bar/foo/baz").should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = true
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == true
+ store.load("bar/foo/baz").should == true
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = true
+ store["foo/bar"] = false
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = true
+ store["bar/foo/baz"].should == true
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = true
+ store.delete("bar/foo/baz").should == true
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = true
+ store["bar/foo/baz"].should == true
+ store["bar/foo/baz"] = false
+ store["bar/foo/baz"].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = true
+ store["bar/foo/baz"].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = true
+ store.fetch("bar/foo/baz", false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = true
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = false
+ store["foo/bar"].should == false
+ store.load("foo/bar").should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = false
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == false
+ store.load("foo/bar").should == false
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = false
+ store["bar/foo/baz"] = true
+ store.clear.should equal(store)
+ store["foo/bar"] = false
+ store["foo/bar"].should == false
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = false
+ store.delete("foo/bar").should == false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = false
+ store["foo/bar"].should == false
+ store["foo/bar"] = true
+ store["foo/bar"].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = false
+ store["foo/bar"].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = false
+ store.fetch("foo/bar", true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = false
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = false
+ store["bar/foo/baz"].should == false
+ store.load("bar/foo/baz").should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = false
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == false
+ store.load("bar/foo/baz").should == false
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = false
+ store["foo/bar"] = true
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = false
+ store["bar/foo/baz"].should == false
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = false
+ store.delete("bar/foo/baz").should == false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = false
+ store["bar/foo/baz"].should == false
+ store["bar/foo/baz"] = true
+ store["bar/foo/baz"].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = false
+ store["bar/foo/baz"].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = false
+ store.fetch("bar/foo/baz", true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = false
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
end
#################### persist_stringkey_booleanvalue ####################
shared_examples_for 'persist_stringkey_booleanvalue' do
@@ -9732,10 +25060,38 @@
store["strkey2"] = false
store.close
@store = nil
store["strkey2"].should == false
end
+
+ it 'persists values' do
+ store["foo/bar"] = true
+ store.close
+ @store = nil
+ store["foo/bar"].should == true
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = true
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == true
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = false
+ store.close
+ @store = nil
+ store["foo/bar"].should == false
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = false
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == false
+ end
end
#################### null_stringkey_stringvalue ####################
shared_examples_for 'null_stringkey_stringvalue' do
@@ -9940,10 +25296,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", "strval2", options).should == "strval2"
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = "strval1"
+ store["bar/foo/baz"] = "strval2"
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = "strval1"
+ store["foo/bar"] = "strval2"
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = "strval2"
+ store["bar/foo/baz"] = "strval1"
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", "strval2", options).should == "strval2"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = "strval2"
+ store["foo/bar"] = "strval1"
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", "strval2", options).should == "strval2"
+ end
end
#################### store_stringkey_stringvalue ####################
shared_examples_for 'store_stringkey_stringvalue' do
@@ -9984,10 +25544,22 @@
store["strkey1"] = "strval1"
store["strkey1"].should == "strval1"
store["strkey1"] = "strval2"
store["strkey1"].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = "strval1"
+ store["strkey1"].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = "strval1"
store.fetch("strkey1", "strval2").should == "strval1"
end
@@ -10035,10 +25607,22 @@
store["strkey2"] = "strval1"
store["strkey2"].should == "strval1"
store["strkey2"] = "strval2"
store["strkey2"].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = "strval1"
+ store["strkey2"].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = "strval1"
store.fetch("strkey2", "strval2").should == "strval1"
end
@@ -10086,10 +25670,22 @@
store["strkey1"] = "strval2"
store["strkey1"].should == "strval2"
store["strkey1"] = "strval1"
store["strkey1"].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = "strval2"
+ store["strkey1"].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = "strval2"
store.fetch("strkey1", "strval1").should == "strval2"
end
@@ -10137,10 +25733,22 @@
store["strkey2"] = "strval2"
store["strkey2"].should == "strval2"
store["strkey2"] = "strval1"
store["strkey2"].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = "strval2"
+ store["strkey2"].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = "strval2"
store.fetch("strkey2", "strval1").should == "strval2"
end
@@ -10148,10 +25756,262 @@
store["strkey2"] = "strval2"
unaltered = 'unaltered'
store.fetch("strkey2") { unaltered = 'altered' }
unaltered.should == 'unaltered'
end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = "strval1"
+ store["foo/bar"].should == "strval1"
+ store.load("foo/bar").should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = "strval1"
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == "strval1"
+ store.load("foo/bar").should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = "strval1"
+ store["bar/foo/baz"] = "strval2"
+ store.clear.should equal(store)
+ store["foo/bar"] = "strval1"
+ store["foo/bar"].should == "strval1"
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = "strval1"
+ store.delete("foo/bar").should == "strval1"
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = "strval1"
+ store["foo/bar"].should == "strval1"
+ store["foo/bar"] = "strval2"
+ store["foo/bar"].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = "strval1"
+ store["foo/bar"].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = "strval1"
+ store.fetch("foo/bar", "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = "strval1"
+ store["bar/foo/baz"].should == "strval1"
+ store.load("bar/foo/baz").should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = "strval1"
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == "strval1"
+ store.load("bar/foo/baz").should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = "strval1"
+ store["foo/bar"] = "strval2"
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = "strval1"
+ store["bar/foo/baz"].should == "strval1"
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = "strval1"
+ store.delete("bar/foo/baz").should == "strval1"
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = "strval1"
+ store["bar/foo/baz"].should == "strval1"
+ store["bar/foo/baz"] = "strval2"
+ store["bar/foo/baz"].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = "strval1"
+ store["bar/foo/baz"].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = "strval1"
+ store.fetch("bar/foo/baz", "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = "strval2"
+ store["foo/bar"].should == "strval2"
+ store.load("foo/bar").should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = "strval2"
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == "strval2"
+ store.load("foo/bar").should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = "strval2"
+ store["bar/foo/baz"] = "strval1"
+ store.clear.should equal(store)
+ store["foo/bar"] = "strval2"
+ store["foo/bar"].should == "strval2"
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = "strval2"
+ store.delete("foo/bar").should == "strval2"
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = "strval2"
+ store["foo/bar"].should == "strval2"
+ store["foo/bar"] = "strval1"
+ store["foo/bar"].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = "strval2"
+ store["foo/bar"].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = "strval2"
+ store.fetch("foo/bar", "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = "strval2"
+ store["bar/foo/baz"].should == "strval2"
+ store.load("bar/foo/baz").should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = "strval2"
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == "strval2"
+ store.load("bar/foo/baz").should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = "strval2"
+ store["foo/bar"] = "strval1"
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = "strval2"
+ store["bar/foo/baz"].should == "strval2"
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = "strval2"
+ store.delete("bar/foo/baz").should == "strval2"
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = "strval2"
+ store["bar/foo/baz"].should == "strval2"
+ store["bar/foo/baz"] = "strval1"
+ store["bar/foo/baz"].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = "strval2"
+ store["bar/foo/baz"].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = "strval2"
+ store.fetch("bar/foo/baz", "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
end
#################### returndifferent_stringkey_stringvalue ####################
shared_examples_for 'returndifferent_stringkey_stringvalue' do
@@ -10176,10 +26036,34 @@
it 'guarantees that a different value is retrieved' do
value = "strval2"
store["strkey2"] = value
store["strkey2"].should_not be_equal(value)
end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
end
#################### returnsame_stringkey_stringvalue ####################
shared_examples_for 'returnsame_stringkey_stringvalue' do
@@ -10204,10 +26088,34 @@
it 'guarantees that the same value is retrieved' do
value = "strval2"
store["strkey2"] = value
store["strkey2"].should be_equal(value)
end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
end
#################### persist_stringkey_stringvalue ####################
shared_examples_for 'persist_stringkey_stringvalue' do
@@ -10236,10 +26144,38 @@
store["strkey2"] = "strval2"
store.close
@store = nil
store["strkey2"].should == "strval2"
end
+
+ it 'persists values' do
+ store["foo/bar"] = "strval1"
+ store.close
+ @store = nil
+ store["foo/bar"].should == "strval1"
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = "strval1"
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == "strval1"
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = "strval2"
+ store.close
+ @store = nil
+ store["foo/bar"].should == "strval2"
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = "strval2"
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == "strval2"
+ end
end
#################### null_stringkey_hashvalue ####################
shared_examples_for 'null_stringkey_hashvalue' do
@@ -10444,10 +26380,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
end
#################### store_stringkey_hashvalue ####################
shared_examples_for 'store_stringkey_hashvalue' do
@@ -10488,10 +26628,22 @@
store["strkey1"] = {"hashval1"=>["array1", 1]}
store["strkey1"].should == {"hashval1"=>["array1", 1]}
store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = {"hashval1"=>["array1", 1]}
store.fetch("strkey1", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -10539,10 +26691,22 @@
store["strkey2"] = {"hashval1"=>["array1", 1]}
store["strkey2"].should == {"hashval1"=>["array1", 1]}
store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = {"hashval1"=>["array1", 1]}
store.fetch("strkey2", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -10590,10 +26754,22 @@
store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey1"] = {"hashval1"=>["array1", 1]}
store["strkey1"].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch("strkey1", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -10641,10 +26817,22 @@
store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey2"] = {"hashval1"=>["array1", 1]}
store["strkey2"].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch("strkey2", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -10652,10 +26840,262 @@
store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
unaltered = 'unaltered'
store.fetch("strkey2") { unaltered = 'altered' }
unaltered.should == 'unaltered'
end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ store.load("foo/bar").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ store.load("foo/bar").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.delete("foo/bar").should == {"hashval1"=>["array1", 1]}
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.fetch("foo/bar", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ store.load("bar/foo/baz").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ store.load("bar/foo/baz").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.delete("bar/foo/baz").should == {"hashval1"=>["array1", 1]}
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.fetch("bar/foo/baz", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("foo/bar").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("foo/bar").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete("foo/bar").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch("foo/bar", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("bar/foo/baz").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("bar/foo/baz").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete("bar/foo/baz").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch("bar/foo/baz", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
end
#################### returndifferent_stringkey_hashvalue ####################
shared_examples_for 'returndifferent_stringkey_hashvalue' do
@@ -10680,10 +27120,34 @@
it 'guarantees that a different value is retrieved' do
value = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey2"] = value
store["strkey2"].should_not be_equal(value)
end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
end
#################### returnsame_stringkey_hashvalue ####################
shared_examples_for 'returnsame_stringkey_hashvalue' do
@@ -10708,10 +27172,34 @@
it 'guarantees that the same value is retrieved' do
value = {"hashval3"=>["array2", {"hashval4"=>42}]}
store["strkey2"] = value
store["strkey2"].should be_equal(value)
end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
end
#################### persist_stringkey_hashvalue ####################
shared_examples_for 'persist_stringkey_hashvalue' do
@@ -10740,10 +27228,38 @@
store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.close
@store = nil
store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'persists values' do
+ store["foo/bar"] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store["foo/bar"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store["foo/bar"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
end
#################### null_stringkey_objectvalue ####################
shared_examples_for 'null_stringkey_objectvalue' do
@@ -10948,10 +27464,214 @@
store.fetch("strkey2", options) { 42 }.should == 42
store.delete("strkey2", options).should be_nil
store.clear(options).should equal(store)
store.store("strkey2", Value.new(:objval2), options).should == Value.new(:objval2)
end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = Value.new(:objval1)
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["foo/bar"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["foo/bar"].should be_nil
+ store.load("foo/bar").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store["foo/bar"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("foo/bar").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["foo/bar"] = Value.new(:objval2)
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?("foo/bar").should be_false
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("foo/bar", Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "foo/bar"
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("foo/bar", options).should be_false
+ store.load("foo/bar", options).should be_nil
+ store.fetch("foo/bar", 42, options).should == 42
+ store.fetch("foo/bar", options) { 42 }.should == 42
+ store.delete("foo/bar", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("foo/bar", Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["bar/foo/baz"].should be_nil
+ store.load("bar/foo/baz").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store["bar/foo/baz"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("bar/foo/baz").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["foo/bar"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?("bar/foo/baz").should be_false
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("bar/foo/baz", Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "bar/foo/baz"
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("bar/foo/baz", options).should be_false
+ store.load("bar/foo/baz", options).should be_nil
+ store.fetch("bar/foo/baz", 42, options).should == 42
+ store.fetch("bar/foo/baz", options) { 42 }.should == 42
+ store.delete("bar/foo/baz", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("bar/foo/baz", Value.new(:objval2), options).should == Value.new(:objval2)
+ end
end
#################### store_stringkey_objectvalue ####################
shared_examples_for 'store_stringkey_objectvalue' do
@@ -10992,10 +27712,22 @@
store["strkey1"] = Value.new(:objval1)
store["strkey1"].should == Value.new(:objval1)
store["strkey1"] = Value.new(:objval2)
store["strkey1"].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = Value.new(:objval1)
store.fetch("strkey1", Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -11043,10 +27775,22 @@
store["strkey2"] = Value.new(:objval1)
store["strkey2"].should == Value.new(:objval1)
store["strkey2"] = Value.new(:objval2)
store["strkey2"].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = Value.new(:objval1)
store.fetch("strkey2", Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -11094,10 +27838,22 @@
store["strkey1"] = Value.new(:objval2)
store["strkey1"].should == Value.new(:objval2)
store["strkey1"] = Value.new(:objval1)
store["strkey1"].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey1"] = Value.new(:objval2)
store.fetch("strkey1", Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -11145,10 +27901,22 @@
store["strkey2"] = Value.new(:objval2)
store["strkey2"].should == Value.new(:objval2)
store["strkey2"] = Value.new(:objval1)
store["strkey2"].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store["strkey2"] = Value.new(:objval2)
store.fetch("strkey2", Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -11156,10 +27924,262 @@
store["strkey2"] = Value.new(:objval2)
unaltered = 'unaltered'
store.fetch("strkey2") { unaltered = 'altered' }
unaltered.should == 'unaltered'
end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = Value.new(:objval1)
+ store["foo/bar"].should == Value.new(:objval1)
+ store.load("foo/bar").should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = Value.new(:objval1)
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == Value.new(:objval1)
+ store.load("foo/bar").should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = Value.new(:objval1)
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store["foo/bar"] = Value.new(:objval1)
+ store["foo/bar"].should == Value.new(:objval1)
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = Value.new(:objval1)
+ store.delete("foo/bar").should == Value.new(:objval1)
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = Value.new(:objval1)
+ store["foo/bar"].should == Value.new(:objval1)
+ store["foo/bar"] = Value.new(:objval2)
+ store["foo/bar"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = Value.new(:objval1)
+ store["foo/bar"].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = Value.new(:objval1)
+ store.fetch("foo/bar", Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ store.load("bar/foo/baz").should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ store.load("bar/foo/baz").should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["foo/bar"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.delete("bar/foo/baz").should == Value.new(:objval1)
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = Value.new(:objval1)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.fetch("bar/foo/baz", Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["foo/bar"] = Value.new(:objval2)
+ store["foo/bar"].should == Value.new(:objval2)
+ store.load("foo/bar").should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["foo/bar"] = Value.new(:objval2)
+ store.key?("foo/bar").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store("foo/bar", value).should equal(value)
+ store["foo/bar"].should == Value.new(:objval2)
+ store.load("foo/bar").should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store["foo/bar"] = Value.new(:objval2)
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store["foo/bar"] = Value.new(:objval2)
+ store["foo/bar"].should == Value.new(:objval2)
+ store["bar/foo/baz"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["foo/bar"] = Value.new(:objval2)
+ store.delete("foo/bar").should == Value.new(:objval2)
+ store.key?("foo/bar").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["foo/bar"] = Value.new(:objval2)
+ store["foo/bar"].should == Value.new(:objval2)
+ store["foo/bar"] = Value.new(:objval1)
+ store["foo/bar"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["foo/bar"] = value).should equal(value)
+ store["foo/bar"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "foo/bar".freeze
+ store[key] = Value.new(:objval2)
+ store["foo/bar"].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["foo/bar"] = Value.new(:objval2)
+ store.fetch("foo/bar", Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["foo/bar"] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch("foo/bar") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ store.load("bar/foo/baz").should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.key?("bar/foo/baz").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store("bar/foo/baz", value).should equal(value)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ store.load("bar/foo/baz").should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["foo/bar"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ store["foo/bar"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.delete("bar/foo/baz").should == Value.new(:objval2)
+ store.key?("bar/foo/baz").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["bar/foo/baz"] = value).should equal(value)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "bar/foo/baz".freeze
+ store[key] = Value.new(:objval2)
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.fetch("bar/foo/baz", Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch("bar/foo/baz") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
end
#################### returndifferent_stringkey_objectvalue ####################
shared_examples_for 'returndifferent_stringkey_objectvalue' do
@@ -11184,10 +28204,34 @@
it 'guarantees that a different value is retrieved' do
value = Value.new(:objval2)
store["strkey2"] = value
store["strkey2"].should_not be_equal(value)
end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store["foo/bar"] = value
+ store["foo/bar"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should_not be_equal(value)
+ end
end
#################### returnsame_stringkey_objectvalue ####################
shared_examples_for 'returnsame_stringkey_objectvalue' do
@@ -11212,10 +28256,34 @@
it 'guarantees that the same value is retrieved' do
value = Value.new(:objval2)
store["strkey2"] = value
store["strkey2"].should be_equal(value)
end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store["foo/bar"] = value
+ store["foo/bar"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store["bar/foo/baz"] = value
+ store["bar/foo/baz"].should be_equal(value)
+ end
end
#################### persist_stringkey_objectvalue ####################
shared_examples_for 'persist_stringkey_objectvalue' do
@@ -11244,12 +28312,4120 @@
store["strkey2"] = Value.new(:objval2)
store.close
@store = nil
store["strkey2"].should == Value.new(:objval2)
end
+
+ it 'persists values' do
+ store["foo/bar"] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store["foo/bar"].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store["foo/bar"] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store["foo/bar"].should == Value.new(:objval2)
+ end
+
+ it 'persists values' do
+ store["bar/foo/baz"] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store["bar/foo/baz"].should == Value.new(:objval2)
+ end
end
+#################### null_simplestringkey_nilvalue ####################
+
+shared_examples_for 'null_simplestringkey_nilvalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 0
+ store["strkey2"] = nil
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 0
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 0
+ store["strkey1"] = nil
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 0).should == 0
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 0
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 0, options).should == 0
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = nil
+ store["strkey2"] = 0
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", nil, options).should == nil
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = nil
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = nil
+ store["strkey1"] = 0
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", nil).should == nil
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = nil
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", nil, options).should == nil
+ end
+end
+
+#################### store_simplestringkey_nilvalue ####################
+
+shared_examples_for 'store_simplestringkey_nilvalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 0
+ store["strkey1"].should == 0
+ store.load("strkey1").should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 0
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 0
+ store.load("strkey1").should == 0
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 0
+ store["strkey2"] = nil
+ store.clear.should equal(store)
+ store["strkey1"] = 0
+ store["strkey1"].should == 0
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 0
+ store.delete("strkey1").should == 0
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 0
+ store["strkey1"].should == 0
+ store["strkey1"] = nil
+ store["strkey1"].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 0
+ store["strkey1"].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 0
+ store["strkey2"].should == 0
+ store.load("strkey2").should == 0
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 0
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 0
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 0
+ store.load("strkey2").should == 0
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 0
+ store["strkey1"] = nil
+ store.clear.should equal(store)
+ store["strkey2"] = 0
+ store["strkey2"].should == 0
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 0
+ store.delete("strkey2").should == 0
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 0
+ store["strkey2"].should == 0
+ store["strkey2"] = nil
+ store["strkey2"].should == nil
+ end
+
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 0
+ store["strkey2"].should == 0
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = nil
+ store["strkey1"].should == nil
+ store.load("strkey1").should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = nil
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == nil
+ store.load("strkey1").should == nil
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = nil
+ store["strkey2"] = 0
+ store.clear.should equal(store)
+ store["strkey1"] = nil
+ store["strkey1"].should == nil
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = nil
+ store.delete("strkey1").should == nil
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = nil
+ store["strkey1"].should == nil
+ store["strkey1"] = 0
+ store["strkey1"].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = nil
+ store["strkey1"].should == nil
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = nil
+ store["strkey2"].should == nil
+ store.load("strkey2").should == nil
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = nil
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = nil
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == nil
+ store.load("strkey2").should == nil
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = nil
+ store["strkey1"] = 0
+ store.clear.should equal(store)
+ store["strkey2"] = nil
+ store["strkey2"].should == nil
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = nil
+ store.delete("strkey2").should == nil
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = nil
+ store["strkey2"].should == nil
+ store["strkey2"] = 0
+ store["strkey2"].should == 0
+ end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = nil
+ store["strkey2"].should == nil
+ end
+end
+
+#################### persist_simplestringkey_nilvalue ####################
+
+shared_examples_for 'persist_simplestringkey_nilvalue' do
+ it 'persists values' do
+ store["strkey1"] = 0
+ store.close
+ @store = nil
+ store["strkey1"].should == 0
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 0
+ store.close
+ @store = nil
+ store["strkey2"].should == 0
+ end
+
+ it 'persists values' do
+ store["strkey1"] = nil
+ store.close
+ @store = nil
+ store["strkey1"].should == nil
+ end
+
+ it 'persists values' do
+ store["strkey2"] = nil
+ store.close
+ @store = nil
+ store["strkey2"].should == nil
+ end
+end
+
+#################### null_simplestringkey_integervalue ####################
+
+shared_examples_for 'null_simplestringkey_integervalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 41
+ store["strkey2"] = -12
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 41
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 41
+ store["strkey1"] = -12
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 41).should == 41
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 41
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 41, options).should == 41
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = -12
+ store["strkey2"] = 41
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", -12, options).should == -12
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -12
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = -12
+ store["strkey1"] = 41
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", -12).should == -12
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = -12
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", -12, options).should == -12
+ end
+end
+
+#################### store_simplestringkey_integervalue ####################
+
+shared_examples_for 'store_simplestringkey_integervalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 41
+ store["strkey1"].should == 41
+ store.load("strkey1").should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 41
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 41
+ store.load("strkey1").should == 41
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 41
+ store["strkey2"] = -12
+ store.clear.should equal(store)
+ store["strkey1"] = 41
+ store["strkey1"].should == 41
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 41
+ store.delete("strkey1").should == 41
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 41
+ store["strkey1"].should == 41
+ store["strkey1"] = -12
+ store["strkey1"].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 41
+ store["strkey1"].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 41
+ store.fetch("strkey1", -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 41
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 41
+ store["strkey2"].should == 41
+ store.load("strkey2").should == 41
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 41
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 41
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 41
+ store.load("strkey2").should == 41
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 41
+ store["strkey1"] = -12
+ store.clear.should equal(store)
+ store["strkey2"] = 41
+ store["strkey2"].should == 41
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 41
+ store.delete("strkey2").should == 41
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 41
+ store["strkey2"].should == 41
+ store["strkey2"] = -12
+ store["strkey2"].should == -12
+ end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 41
+ store["strkey2"].should == 41
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 41
+ store.fetch("strkey2", -12).should == 41
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 41
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = -12
+ store["strkey1"].should == -12
+ store.load("strkey1").should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = -12
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == -12
+ store.load("strkey1").should == -12
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = -12
+ store["strkey2"] = 41
+ store.clear.should equal(store)
+ store["strkey1"] = -12
+ store["strkey1"].should == -12
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = -12
+ store.delete("strkey1").should == -12
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = -12
+ store["strkey1"].should == -12
+ store["strkey1"] = 41
+ store["strkey1"].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = -12
+ store["strkey1"].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = -12
+ store.fetch("strkey1", 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = -12
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = -12
+ store["strkey2"].should == -12
+ store.load("strkey2").should == -12
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = -12
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -12
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == -12
+ store.load("strkey2").should == -12
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = -12
+ store["strkey1"] = 41
+ store.clear.should equal(store)
+ store["strkey2"] = -12
+ store["strkey2"].should == -12
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = -12
+ store.delete("strkey2").should == -12
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = -12
+ store["strkey2"].should == -12
+ store["strkey2"] = 41
+ store["strkey2"].should == 41
+ end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = -12
+ store["strkey2"].should == -12
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = -12
+ store.fetch("strkey2", 41).should == -12
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = -12
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_simplestringkey_integervalue ####################
+
+shared_examples_for 'persist_simplestringkey_integervalue' do
+ it 'persists values' do
+ store["strkey1"] = 41
+ store.close
+ @store = nil
+ store["strkey1"].should == 41
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 41
+ store.close
+ @store = nil
+ store["strkey2"].should == 41
+ end
+
+ it 'persists values' do
+ store["strkey1"] = -12
+ store.close
+ @store = nil
+ store["strkey1"].should == -12
+ end
+
+ it 'persists values' do
+ store["strkey2"] = -12
+ store.close
+ @store = nil
+ store["strkey2"].should == -12
+ end
+end
+
+#################### null_simplestringkey_numbervalue ####################
+
+shared_examples_for 'null_simplestringkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 123.456
+ store["strkey2"] = -98.7
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 123.456
+ store["strkey1"] = -98.7
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = -98.7
+ store["strkey2"] = 123.456
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = -98.7
+ store["strkey1"] = 123.456
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", 33, options).should == 33
+ end
+end
+
+#################### store_simplestringkey_numbervalue ####################
+
+shared_examples_for 'store_simplestringkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store.load("strkey1").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 123.456
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 123.456
+ store.load("strkey1").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 123.456
+ store["strkey2"] = -98.7
+ store.clear.should equal(store)
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 123.456
+ store.delete("strkey1").should == 123.456
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 123.456
+ store["strkey1"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 123.456
+ store.fetch("strkey1", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store.load("strkey2").should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 123.456
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 123.456
+ store.load("strkey2").should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 123.456
+ store["strkey1"] = -98.7
+ store.clear.should equal(store)
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 123.456
+ store.delete("strkey2").should == 123.456
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 123.456
+ store["strkey2"].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 123.456
+ store.fetch("strkey2", -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 123.456
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store.load("strkey1").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = -98.7
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == -98.7
+ store.load("strkey1").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = -98.7
+ store["strkey2"] = 123.456
+ store.clear.should equal(store)
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = -98.7
+ store.delete("strkey1").should == -98.7
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = -98.7
+ store["strkey1"].should == -98.7
+ store["strkey1"] = 123.456
+ store["strkey1"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = -98.7
+ store["strkey1"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = -98.7
+ store.fetch("strkey1", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store.load("strkey2").should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = -98.7
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == -98.7
+ store.load("strkey2").should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = -98.7
+ store["strkey1"] = 123.456
+ store.clear.should equal(store)
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = -98.7
+ store.delete("strkey2").should == -98.7
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = -98.7
+ store["strkey2"].should == -98.7
+ store["strkey2"] = 123.456
+ store["strkey2"].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = -98.7
+ store["strkey2"].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = -98.7
+ store.fetch("strkey2", 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = -98.7
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store.load("strkey1").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store.load("strkey1").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store.clear.should equal(store)
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.delete("strkey1").should == 340282366920938463463374607431768211456
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.fetch("strkey1", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store.load("strkey2").should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store.load("strkey2").should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey1"] = 33
+ store.clear.should equal(store)
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.delete("strkey2").should == 340282366920938463463374607431768211456
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.fetch("strkey2", 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store.load("strkey1").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = 33
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == 33
+ store.load("strkey1").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = 33
+ store.delete("strkey1").should == 33
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = 33
+ store["strkey1"].should == 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = 33
+ store["strkey1"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = 33
+ store.fetch("strkey1", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = 33
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store.load("strkey2").should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = 33
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == 33
+ store.load("strkey2").should == 33
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = 33
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = 33
+ store.delete("strkey2").should == 33
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = 33
+ store["strkey2"].should == 33
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = 33
+ store["strkey2"].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = 33
+ store.fetch("strkey2", 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = 33
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_simplestringkey_numbervalue ####################
+
+shared_examples_for 'persist_simplestringkey_numbervalue' do
+ it 'persists values' do
+ store["strkey1"] = 123.456
+ store.close
+ @store = nil
+ store["strkey1"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 123.456
+ store.close
+ @store = nil
+ store["strkey2"].should == 123.456
+ end
+
+ it 'persists values' do
+ store["strkey1"] = -98.7
+ store.close
+ @store = nil
+ store["strkey1"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["strkey2"] = -98.7
+ store.close
+ @store = nil
+ store["strkey2"].should == -98.7
+ end
+
+ it 'persists values' do
+ store["strkey1"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["strkey1"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store["strkey2"].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store["strkey1"] = 33
+ store.close
+ @store = nil
+ store["strkey1"].should == 33
+ end
+
+ it 'persists values' do
+ store["strkey2"] = 33
+ store.close
+ @store = nil
+ store["strkey2"].should == 33
+ end
+end
+
+#################### null_simplestringkey_booleanvalue ####################
+
+shared_examples_for 'null_simplestringkey_booleanvalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = true
+ store["strkey2"] = false
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = true
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = true
+ store["strkey1"] = false
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", true).should == true
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = true
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", true, options).should == true
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = false
+ store["strkey2"] = true
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", false, options).should == false
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = false
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = false
+ store["strkey1"] = true
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", false).should == false
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = false
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", false, options).should == false
+ end
+end
+
+#################### store_simplestringkey_booleanvalue ####################
+
+shared_examples_for 'store_simplestringkey_booleanvalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = true
+ store["strkey1"].should == true
+ store.load("strkey1").should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = true
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == true
+ store.load("strkey1").should == true
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = true
+ store["strkey2"] = false
+ store.clear.should equal(store)
+ store["strkey1"] = true
+ store["strkey1"].should == true
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = true
+ store.delete("strkey1").should == true
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = true
+ store["strkey1"].should == true
+ store["strkey1"] = false
+ store["strkey1"].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = true
+ store["strkey1"].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = true
+ store.fetch("strkey1", false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = true
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = true
+ store["strkey2"].should == true
+ store.load("strkey2").should == true
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = true
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = true
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == true
+ store.load("strkey2").should == true
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = true
+ store["strkey1"] = false
+ store.clear.should equal(store)
+ store["strkey2"] = true
+ store["strkey2"].should == true
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = true
+ store.delete("strkey2").should == true
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = true
+ store["strkey2"].should == true
+ store["strkey2"] = false
+ store["strkey2"].should == false
+ end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = true
+ store["strkey2"].should == true
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = true
+ store.fetch("strkey2", false).should == true
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = true
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = false
+ store["strkey1"].should == false
+ store.load("strkey1").should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = false
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == false
+ store.load("strkey1").should == false
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = false
+ store["strkey2"] = true
+ store.clear.should equal(store)
+ store["strkey1"] = false
+ store["strkey1"].should == false
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = false
+ store.delete("strkey1").should == false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = false
+ store["strkey1"].should == false
+ store["strkey1"] = true
+ store["strkey1"].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = false
+ store["strkey1"].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = false
+ store.fetch("strkey1", true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = false
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = false
+ store["strkey2"].should == false
+ store.load("strkey2").should == false
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = false
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = false
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == false
+ store.load("strkey2").should == false
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = false
+ store["strkey1"] = true
+ store.clear.should equal(store)
+ store["strkey2"] = false
+ store["strkey2"].should == false
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = false
+ store.delete("strkey2").should == false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = false
+ store["strkey2"].should == false
+ store["strkey2"] = true
+ store["strkey2"].should == true
+ end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = false
+ store["strkey2"].should == false
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = false
+ store.fetch("strkey2", true).should == false
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = false
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_simplestringkey_booleanvalue ####################
+
+shared_examples_for 'persist_simplestringkey_booleanvalue' do
+ it 'persists values' do
+ store["strkey1"] = true
+ store.close
+ @store = nil
+ store["strkey1"].should == true
+ end
+
+ it 'persists values' do
+ store["strkey2"] = true
+ store.close
+ @store = nil
+ store["strkey2"].should == true
+ end
+
+ it 'persists values' do
+ store["strkey1"] = false
+ store.close
+ @store = nil
+ store["strkey1"].should == false
+ end
+
+ it 'persists values' do
+ store["strkey2"] = false
+ store.close
+ @store = nil
+ store["strkey2"].should == false
+ end
+end
+
+#################### null_simplestringkey_stringvalue ####################
+
+shared_examples_for 'null_simplestringkey_stringvalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = "strval1"
+ store["strkey2"] = "strval2"
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval1"
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = "strval1"
+ store["strkey1"] = "strval2"
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", "strval1").should == "strval1"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = "strval1"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", "strval1", options).should == "strval1"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = "strval2"
+ store["strkey2"] = "strval1"
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", "strval2", options).should == "strval2"
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = "strval2"
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = "strval2"
+ store["strkey1"] = "strval1"
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", "strval2").should == "strval2"
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = "strval2"
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", "strval2", options).should == "strval2"
+ end
+end
+
+#################### store_simplestringkey_stringvalue ####################
+
+shared_examples_for 'store_simplestringkey_stringvalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = "strval1"
+ store["strkey1"].should == "strval1"
+ store.load("strkey1").should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = "strval1"
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == "strval1"
+ store.load("strkey1").should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = "strval1"
+ store["strkey2"] = "strval2"
+ store.clear.should equal(store)
+ store["strkey1"] = "strval1"
+ store["strkey1"].should == "strval1"
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = "strval1"
+ store.delete("strkey1").should == "strval1"
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = "strval1"
+ store["strkey1"].should == "strval1"
+ store["strkey1"] = "strval2"
+ store["strkey1"].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = "strval1"
+ store["strkey1"].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = "strval1"
+ store.fetch("strkey1", "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = "strval1"
+ store["strkey2"].should == "strval1"
+ store.load("strkey2").should == "strval1"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = "strval1"
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval1"
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == "strval1"
+ store.load("strkey2").should == "strval1"
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = "strval1"
+ store["strkey1"] = "strval2"
+ store.clear.should equal(store)
+ store["strkey2"] = "strval1"
+ store["strkey2"].should == "strval1"
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = "strval1"
+ store.delete("strkey2").should == "strval1"
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = "strval1"
+ store["strkey2"].should == "strval1"
+ store["strkey2"] = "strval2"
+ store["strkey2"].should == "strval2"
+ end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = "strval1"
+ store["strkey2"].should == "strval1"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = "strval1"
+ store.fetch("strkey2", "strval2").should == "strval1"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = "strval1"
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = "strval2"
+ store["strkey1"].should == "strval2"
+ store.load("strkey1").should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = "strval2"
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == "strval2"
+ store.load("strkey1").should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = "strval2"
+ store["strkey2"] = "strval1"
+ store.clear.should equal(store)
+ store["strkey1"] = "strval2"
+ store["strkey1"].should == "strval2"
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = "strval2"
+ store.delete("strkey1").should == "strval2"
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = "strval2"
+ store["strkey1"].should == "strval2"
+ store["strkey1"] = "strval1"
+ store["strkey1"].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = "strval2"
+ store["strkey1"].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = "strval2"
+ store.fetch("strkey1", "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = "strval2"
+ store["strkey2"].should == "strval2"
+ store.load("strkey2").should == "strval2"
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = "strval2"
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = "strval2"
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == "strval2"
+ store.load("strkey2").should == "strval2"
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = "strval2"
+ store["strkey1"] = "strval1"
+ store.clear.should equal(store)
+ store["strkey2"] = "strval2"
+ store["strkey2"].should == "strval2"
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = "strval2"
+ store.delete("strkey2").should == "strval2"
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = "strval2"
+ store["strkey2"].should == "strval2"
+ store["strkey2"] = "strval1"
+ store["strkey2"].should == "strval1"
+ end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = "strval2"
+ store["strkey2"].should == "strval2"
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = "strval2"
+ store.fetch("strkey2", "strval1").should == "strval2"
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = "strval2"
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_simplestringkey_stringvalue ####################
+
+shared_examples_for 'returndifferent_simplestringkey_stringvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval1"
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = "strval2"
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_simplestringkey_stringvalue ####################
+
+shared_examples_for 'returnsame_simplestringkey_stringvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval1"
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = "strval2"
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+end
+
+#################### persist_simplestringkey_stringvalue ####################
+
+shared_examples_for 'persist_simplestringkey_stringvalue' do
+ it 'persists values' do
+ store["strkey1"] = "strval1"
+ store.close
+ @store = nil
+ store["strkey1"].should == "strval1"
+ end
+
+ it 'persists values' do
+ store["strkey2"] = "strval1"
+ store.close
+ @store = nil
+ store["strkey2"].should == "strval1"
+ end
+
+ it 'persists values' do
+ store["strkey1"] = "strval2"
+ store.close
+ @store = nil
+ store["strkey1"].should == "strval2"
+ end
+
+ it 'persists values' do
+ store["strkey2"] = "strval2"
+ store.close
+ @store = nil
+ store["strkey2"].should == "strval2"
+ end
+end
+
+#################### null_simplestringkey_hashvalue ####################
+
+shared_examples_for 'null_simplestringkey_hashvalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval1"=>["array1", 1]}
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", {"hashval1"=>["array1", 1]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = {"hashval1"=>["array1", 1]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", {"hashval1"=>["array1", 1]}, options).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", {"hashval3"=>["array2", {"hashval4"=>42}]}, options).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+end
+
+#################### store_simplestringkey_hashvalue ####################
+
+shared_examples_for 'store_simplestringkey_hashvalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ store.load("strkey1").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ store.load("strkey1").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.delete("strkey1").should == {"hashval1"=>["array1", 1]}
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.fetch("strkey1", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ store.load("strkey2").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval1"=>["array1", 1]}
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ store.load("strkey2").should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.clear.should equal(store)
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.delete("strkey2").should == {"hashval1"=>["array1", 1]}
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.fetch("strkey2", {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("strkey1").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("strkey1").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete("strkey1").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch("strkey1", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("strkey2").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.load("strkey2").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.clear.should equal(store)
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.delete("strkey2").should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.fetch("strkey2", {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_simplestringkey_hashvalue ####################
+
+shared_examples_for 'returndifferent_simplestringkey_hashvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_simplestringkey_hashvalue ####################
+
+shared_examples_for 'returnsame_simplestringkey_hashvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval1"=>["array1", 1]}
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+end
+
+#################### persist_simplestringkey_hashvalue ####################
+
+shared_examples_for 'persist_simplestringkey_hashvalue' do
+ it 'persists values' do
+ store["strkey1"] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store["strkey1"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store["strkey2"] = {"hashval1"=>["array1", 1]}
+ store.close
+ @store = nil
+ store["strkey2"].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'persists values' do
+ store["strkey1"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store["strkey1"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'persists values' do
+ store["strkey2"] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store.close
+ @store = nil
+ store["strkey2"].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+end
+
+#################### null_simplestringkey_objectvalue ####################
+
+shared_examples_for 'null_simplestringkey_objectvalue' do
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey2"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval1)
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey1"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", Value.new(:objval1)).should == Value.new(:objval1)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = Value.new(:objval1)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", Value.new(:objval1), options).should == Value.new(:objval1)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey1"].should be_nil
+ store.load("strkey1").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store["strkey1"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey1").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey1").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey2"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?("strkey1").should be_false
+ store.key?("strkey2").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey1", Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey1"
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey1", options).should be_false
+ store.load("strkey1", options).should be_nil
+ store.fetch("strkey1", 42, options).should == 42
+ store.fetch("strkey1", options) { 42 }.should == 42
+ store.delete("strkey1", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey1", Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+
+ it 'reads from keys like a Hash' do
+ store["strkey2"].should be_nil
+ store.load("strkey2").should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = Value.new(:objval2)
+ (store["strkey2"] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?("strkey2").should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete("strkey2").should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey1"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store.key?("strkey2").should be_false
+ store.key?("strkey1").should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch("strkey2", Value.new(:objval2)).should == Value.new(:objval2)
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = "strkey2"
+ value = Value.new(:objval2)
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?("strkey2", options).should be_false
+ store.load("strkey2", options).should be_nil
+ store.fetch("strkey2", 42, options).should == 42
+ store.fetch("strkey2", options) { 42 }.should == 42
+ store.delete("strkey2", options).should be_nil
+ store.clear(options).should equal(store)
+ store.store("strkey2", Value.new(:objval2), options).should == Value.new(:objval2)
+ end
+end
+
+#################### store_simplestringkey_objectvalue ####################
+
+shared_examples_for 'store_simplestringkey_objectvalue' do
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ store.load("strkey1").should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = Value.new(:objval1)
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == Value.new(:objval1)
+ store.load("strkey1").should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey2"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = Value.new(:objval1)
+ store.delete("strkey1").should == Value.new(:objval1)
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = Value.new(:objval1)
+ store.fetch("strkey1", Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ store.load("strkey2").should == Value.new(:objval1)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = Value.new(:objval1)
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval1)
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == Value.new(:objval1)
+ store.load("strkey2").should == Value.new(:objval1)
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey1"] = Value.new(:objval2)
+ store.clear.should equal(store)
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = Value.new(:objval1)
+ store.delete("strkey2").should == Value.new(:objval1)
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = Value.new(:objval1)
+ store.fetch("strkey2", Value.new(:objval2)).should == Value.new(:objval1)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = Value.new(:objval1)
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ store.load("strkey1").should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey1"] = Value.new(:objval2)
+ store.key?("strkey1").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store("strkey1", value).should equal(value)
+ store["strkey1"].should == Value.new(:objval2)
+ store.load("strkey1").should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey2"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ store["strkey2"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey1"] = Value.new(:objval2)
+ store.delete("strkey1").should == Value.new(:objval2)
+ store.key?("strkey1").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey1"] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ store["strkey1"] = Value.new(:objval1)
+ store["strkey1"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["strkey1"] = value).should equal(value)
+ store["strkey1"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey1".freeze
+ store[key] = Value.new(:objval2)
+ store["strkey1"].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey1"] = Value.new(:objval2)
+ store.fetch("strkey1", Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey1"] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch("strkey1") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ store.load("strkey2").should == Value.new(:objval2)
+ end
+
+ it 'returns true from key? if a key is available' do
+ store["strkey2"] = Value.new(:objval2)
+ store.key?("strkey2").should be_true
+ end
+
+ it 'stores values with #store' do
+ value = Value.new(:objval2)
+ store.store("strkey2", value).should equal(value)
+ store["strkey2"].should == Value.new(:objval2)
+ store.load("strkey2").should == Value.new(:objval2)
+ end
+
+ it 'stores values after clear' do
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey1"] = Value.new(:objval1)
+ store.clear.should equal(store)
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ store["strkey1"].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store["strkey2"] = Value.new(:objval2)
+ store.delete("strkey2").should == Value.new(:objval2)
+ store.key?("strkey2").should be_false
+ end
+
+ it 'overwrites existing values' do
+ store["strkey2"] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ store["strkey2"] = Value.new(:objval1)
+ store["strkey2"].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store["strkey2"] = value).should equal(value)
+ store["strkey2"].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = "strkey2".freeze
+ store[key] = Value.new(:objval2)
+ store["strkey2"].should == Value.new(:objval2)
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store["strkey2"] = Value.new(:objval2)
+ store.fetch("strkey2", Value.new(:objval1)).should == Value.new(:objval2)
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store["strkey2"] = Value.new(:objval2)
+ unaltered = 'unaltered'
+ store.fetch("strkey2") { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### returndifferent_simplestringkey_objectvalue ####################
+
+shared_examples_for 'returndifferent_simplestringkey_objectvalue' do
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval1)
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store["strkey1"] = value
+ store["strkey1"].should_not be_equal(value)
+ end
+
+ it 'guarantees that a different value is retrieved' do
+ value = Value.new(:objval2)
+ store["strkey2"] = value
+ store["strkey2"].should_not be_equal(value)
+ end
+end
+
+#################### returnsame_simplestringkey_objectvalue ####################
+
+shared_examples_for 'returnsame_simplestringkey_objectvalue' do
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval1)
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store["strkey1"] = value
+ store["strkey1"].should be_equal(value)
+ end
+
+ it 'guarantees that the same value is retrieved' do
+ value = Value.new(:objval2)
+ store["strkey2"] = value
+ store["strkey2"].should be_equal(value)
+ end
+end
+
+#################### persist_simplestringkey_objectvalue ####################
+
+shared_examples_for 'persist_simplestringkey_objectvalue' do
+ it 'persists values' do
+ store["strkey1"] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store["strkey1"].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store["strkey2"] = Value.new(:objval1)
+ store.close
+ @store = nil
+ store["strkey2"].should == Value.new(:objval1)
+ end
+
+ it 'persists values' do
+ store["strkey1"] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store["strkey1"].should == Value.new(:objval2)
+ end
+
+ it 'persists values' do
+ store["strkey2"] = Value.new(:objval2)
+ store.close
+ @store = nil
+ store["strkey2"].should == Value.new(:objval2)
+ end
+end
+
#################### null_objectkey_nilvalue ####################
shared_examples_for 'null_objectkey_nilvalue' do
it 'reads from keys like a Hash' do
store[Value.new(:objkey1)].should be_nil
@@ -11497,10 +32673,22 @@
store[Value.new(:objkey1)].should == 0
store[Value.new(:objkey1)] = nil
store[Value.new(:objkey1)].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = 0
+ store[Value.new(:objkey1)].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[Value.new(:objkey2)] = 0
store[Value.new(:objkey2)].should == 0
store.load(Value.new(:objkey2)).should == 0
end
@@ -11537,10 +32725,22 @@
store[Value.new(:objkey2)].should == 0
store[Value.new(:objkey2)] = nil
store[Value.new(:objkey2)].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = 0
+ store[Value.new(:objkey2)].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[Value.new(:objkey1)] = nil
store[Value.new(:objkey1)].should == nil
store.load(Value.new(:objkey1)).should == nil
end
@@ -11577,10 +32777,22 @@
store[Value.new(:objkey1)].should == nil
store[Value.new(:objkey1)] = 0
store[Value.new(:objkey1)].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = nil
+ store[Value.new(:objkey1)].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store[Value.new(:objkey2)] = nil
store[Value.new(:objkey2)].should == nil
store.load(Value.new(:objkey2)).should == nil
end
@@ -11616,10 +32828,22 @@
store[Value.new(:objkey2)] = nil
store[Value.new(:objkey2)].should == nil
store[Value.new(:objkey2)] = 0
store[Value.new(:objkey2)].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = nil
+ store[Value.new(:objkey2)].should == nil
+ end
end
#################### persist_objectkey_nilvalue ####################
shared_examples_for 'persist_objectkey_nilvalue' do
@@ -11900,10 +33124,22 @@
store[Value.new(:objkey1)] = 41
store[Value.new(:objkey1)].should == 41
store[Value.new(:objkey1)] = -12
store[Value.new(:objkey1)].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = 41
+ store[Value.new(:objkey1)].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = 41
store.fetch(Value.new(:objkey1), -12).should == 41
end
@@ -11951,10 +33187,22 @@
store[Value.new(:objkey2)] = 41
store[Value.new(:objkey2)].should == 41
store[Value.new(:objkey2)] = -12
store[Value.new(:objkey2)].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = 41
+ store[Value.new(:objkey2)].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = 41
store.fetch(Value.new(:objkey2), -12).should == 41
end
@@ -12002,10 +33250,22 @@
store[Value.new(:objkey1)] = -12
store[Value.new(:objkey1)].should == -12
store[Value.new(:objkey1)] = 41
store[Value.new(:objkey1)].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = -12
+ store[Value.new(:objkey1)].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = -12
store.fetch(Value.new(:objkey1), 41).should == -12
end
@@ -12053,10 +33313,22 @@
store[Value.new(:objkey2)] = -12
store[Value.new(:objkey2)].should == -12
store[Value.new(:objkey2)] = 41
store[Value.new(:objkey2)].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = -12
+ store[Value.new(:objkey2)].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = -12
store.fetch(Value.new(:objkey2), 41).should == -12
end
@@ -12098,10 +33370,990 @@
@store = nil
store[Value.new(:objkey2)].should == -12
end
end
+#################### null_objectkey_numbervalue ####################
+
+shared_examples_for 'null_objectkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey1)].should be_nil
+ store.load(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey2)] = -98.7
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey1)).should be_false
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey1), 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey1)
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey1), options).should be_false
+ store.load(Value.new(:objkey1), options).should be_nil
+ store.fetch(Value.new(:objkey1), 42, options).should == 42
+ store.fetch(Value.new(:objkey1), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey1), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey1), 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey2)].should be_nil
+ store.load(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey1)] = -98.7
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey2)).should be_false
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey2), 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey2)
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey2), options).should be_false
+ store.load(Value.new(:objkey2), options).should be_nil
+ store.fetch(Value.new(:objkey2), 42, options).should == 42
+ store.fetch(Value.new(:objkey2), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey2), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey2), 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey1)].should be_nil
+ store.load(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey2)] = 123.456
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey1)).should be_false
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey1), -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey1)
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey1), options).should be_false
+ store.load(Value.new(:objkey1), options).should be_nil
+ store.fetch(Value.new(:objkey1), 42, options).should == 42
+ store.fetch(Value.new(:objkey1), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey1), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey1), -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey2)].should be_nil
+ store.load(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey1)] = 123.456
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey2)).should be_false
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey2), -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey2)
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey2), options).should be_false
+ store.load(Value.new(:objkey2), options).should be_nil
+ store.fetch(Value.new(:objkey2), 42, options).should == 42
+ store.fetch(Value.new(:objkey2), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey2), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey2), -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey1)].should be_nil
+ store.load(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)] = 33
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey1)).should be_false
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey1), 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey1)
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey1), options).should be_false
+ store.load(Value.new(:objkey1), options).should be_nil
+ store.fetch(Value.new(:objkey1), 42, options).should == 42
+ store.fetch(Value.new(:objkey1), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey1), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey1), 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey2)].should be_nil
+ store.load(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)] = 33
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey2)).should be_false
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey2), 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey2)
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey2), options).should be_false
+ store.load(Value.new(:objkey2), options).should be_nil
+ store.fetch(Value.new(:objkey2), 42, options).should == 42
+ store.fetch(Value.new(:objkey2), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey2), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey2), 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey1)].should be_nil
+ store.load(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey1)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey1)).should be_false
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey1), 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey1)
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey1), options).should be_false
+ store.load(Value.new(:objkey1), options).should be_nil
+ store.fetch(Value.new(:objkey1), 42, options).should == 42
+ store.fetch(Value.new(:objkey1), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey1), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey1), 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[Value.new(:objkey2)].should be_nil
+ store.load(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete(Value.new(:objkey2)).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?(Value.new(:objkey2)).should be_false
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch(Value.new(:objkey2), 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = Value.new(:objkey2)
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?(Value.new(:objkey2), options).should be_false
+ store.load(Value.new(:objkey2), options).should be_nil
+ store.fetch(Value.new(:objkey2), 42, options).should == 42
+ store.fetch(Value.new(:objkey2), options) { 42 }.should == 42
+ store.delete(Value.new(:objkey2), options).should be_nil
+ store.clear(options).should equal(store)
+ store.store(Value.new(:objkey2), 33, options).should == 33
+ end
+end
+
+#################### store_objectkey_numbervalue ####################
+
+shared_examples_for 'store_objectkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey1)].should == 123.456
+ store.load(Value.new(:objkey1)).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey1)] = 123.456
+ store.key?(Value.new(:objkey1)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(Value.new(:objkey1), value).should equal(value)
+ store[Value.new(:objkey1)].should == 123.456
+ store.load(Value.new(:objkey1)).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey2)] = -98.7
+ store.clear.should equal(store)
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey1)].should == 123.456
+ store[Value.new(:objkey2)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey1)] = 123.456
+ store.delete(Value.new(:objkey1)).should == 123.456
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey1)].should == 123.456
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey1)].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = 123.456
+ store[Value.new(:objkey1)].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey1)] = 123.456
+ store.fetch(Value.new(:objkey1), -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey1)] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey1)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey2)].should == 123.456
+ store.load(Value.new(:objkey2)).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey2)] = 123.456
+ store.key?(Value.new(:objkey2)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store(Value.new(:objkey2), value).should equal(value)
+ store[Value.new(:objkey2)].should == 123.456
+ store.load(Value.new(:objkey2)).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey1)] = -98.7
+ store.clear.should equal(store)
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey2)].should == 123.456
+ store[Value.new(:objkey1)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey2)] = 123.456
+ store.delete(Value.new(:objkey2)).should == 123.456
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey2)].should == 123.456
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey2)].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = 123.456
+ store[Value.new(:objkey2)].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey2)] = 123.456
+ store.fetch(Value.new(:objkey2), -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey2)] = 123.456
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey2)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey1)].should == -98.7
+ store.load(Value.new(:objkey1)).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey1)] = -98.7
+ store.key?(Value.new(:objkey1)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(Value.new(:objkey1), value).should equal(value)
+ store[Value.new(:objkey1)].should == -98.7
+ store.load(Value.new(:objkey1)).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey2)] = 123.456
+ store.clear.should equal(store)
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey1)].should == -98.7
+ store[Value.new(:objkey2)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey1)] = -98.7
+ store.delete(Value.new(:objkey1)).should == -98.7
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey1)] = -98.7
+ store[Value.new(:objkey1)].should == -98.7
+ store[Value.new(:objkey1)] = 123.456
+ store[Value.new(:objkey1)].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = -98.7
+ store[Value.new(:objkey1)].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey1)] = -98.7
+ store.fetch(Value.new(:objkey1), 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey1)] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey1)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey2)].should == -98.7
+ store.load(Value.new(:objkey2)).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey2)] = -98.7
+ store.key?(Value.new(:objkey2)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store(Value.new(:objkey2), value).should equal(value)
+ store[Value.new(:objkey2)].should == -98.7
+ store.load(Value.new(:objkey2)).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey1)] = 123.456
+ store.clear.should equal(store)
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey2)].should == -98.7
+ store[Value.new(:objkey1)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey2)] = -98.7
+ store.delete(Value.new(:objkey2)).should == -98.7
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey2)] = -98.7
+ store[Value.new(:objkey2)].should == -98.7
+ store[Value.new(:objkey2)] = 123.456
+ store[Value.new(:objkey2)].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = -98.7
+ store[Value.new(:objkey2)].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey2)] = -98.7
+ store.fetch(Value.new(:objkey2), 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey2)] = -98.7
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey2)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ store.load(Value.new(:objkey1)).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.key?(Value.new(:objkey1)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(Value.new(:objkey1), value).should equal(value)
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ store.load(Value.new(:objkey1)).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)] = 33
+ store.clear.should equal(store)
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.delete(Value.new(:objkey1)).should == 340282366920938463463374607431768211456
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey1)].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.fetch(Value.new(:objkey1), 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey1)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ store.load(Value.new(:objkey2)).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.key?(Value.new(:objkey2)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store(Value.new(:objkey2), value).should equal(value)
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ store.load(Value.new(:objkey2)).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)] = 33
+ store.clear.should equal(store)
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.delete(Value.new(:objkey2)).should == 340282366920938463463374607431768211456
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey2)].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.fetch(Value.new(:objkey2), 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey2)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey1)].should == 33
+ store.load(Value.new(:objkey1)).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey1)] = 33
+ store.key?(Value.new(:objkey1)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(Value.new(:objkey1), value).should equal(value)
+ store[Value.new(:objkey1)].should == 33
+ store.load(Value.new(:objkey1)).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey1)].should == 33
+ store[Value.new(:objkey2)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey1)] = 33
+ store.delete(Value.new(:objkey1)).should == 33
+ store.key?(Value.new(:objkey1)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey1)] = 33
+ store[Value.new(:objkey1)].should == 33
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = 33
+ store[Value.new(:objkey1)].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey1)] = 33
+ store.fetch(Value.new(:objkey1), 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey1)] = 33
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey1)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey2)].should == 33
+ store.load(Value.new(:objkey2)).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[Value.new(:objkey2)] = 33
+ store.key?(Value.new(:objkey2)).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store(Value.new(:objkey2), value).should equal(value)
+ store[Value.new(:objkey2)].should == 33
+ store.load(Value.new(:objkey2)).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey2)].should == 33
+ store[Value.new(:objkey1)].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[Value.new(:objkey2)] = 33
+ store.delete(Value.new(:objkey2)).should == 33
+ store.key?(Value.new(:objkey2)).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[Value.new(:objkey2)] = 33
+ store[Value.new(:objkey2)].should == 33
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = 33
+ store[Value.new(:objkey2)].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[Value.new(:objkey2)] = 33
+ store.fetch(Value.new(:objkey2), 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[Value.new(:objkey2)] = 33
+ unaltered = 'unaltered'
+ store.fetch(Value.new(:objkey2)) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_objectkey_numbervalue ####################
+
+shared_examples_for 'persist_objectkey_numbervalue' do
+ it 'persists values' do
+ store[Value.new(:objkey1)] = 123.456
+ store.close
+ @store = nil
+ store[Value.new(:objkey1)].should == 123.456
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey2)] = 123.456
+ store.close
+ @store = nil
+ store[Value.new(:objkey2)].should == 123.456
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey1)] = -98.7
+ store.close
+ @store = nil
+ store[Value.new(:objkey1)].should == -98.7
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey2)] = -98.7
+ store.close
+ @store = nil
+ store[Value.new(:objkey2)].should == -98.7
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey1)] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[Value.new(:objkey1)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey2)] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[Value.new(:objkey2)].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey1)] = 33
+ store.close
+ @store = nil
+ store[Value.new(:objkey1)].should == 33
+ end
+
+ it 'persists values' do
+ store[Value.new(:objkey2)] = 33
+ store.close
+ @store = nil
+ store[Value.new(:objkey2)].should == 33
+ end
+end
+
#################### null_objectkey_booleanvalue ####################
shared_examples_for 'null_objectkey_booleanvalue' do
it 'reads from keys like a Hash' do
store[Value.new(:objkey1)].should be_nil
@@ -12348,10 +34600,22 @@
store[Value.new(:objkey1)] = true
store[Value.new(:objkey1)].should == true
store[Value.new(:objkey1)] = false
store[Value.new(:objkey1)].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = true
+ store[Value.new(:objkey1)].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = true
store.fetch(Value.new(:objkey1), false).should == true
end
@@ -12399,10 +34663,22 @@
store[Value.new(:objkey2)] = true
store[Value.new(:objkey2)].should == true
store[Value.new(:objkey2)] = false
store[Value.new(:objkey2)].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = true
+ store[Value.new(:objkey2)].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = true
store.fetch(Value.new(:objkey2), false).should == true
end
@@ -12450,10 +34726,22 @@
store[Value.new(:objkey1)] = false
store[Value.new(:objkey1)].should == false
store[Value.new(:objkey1)] = true
store[Value.new(:objkey1)].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = false
+ store[Value.new(:objkey1)].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = false
store.fetch(Value.new(:objkey1), true).should == false
end
@@ -12501,10 +34789,22 @@
store[Value.new(:objkey2)] = false
store[Value.new(:objkey2)].should == false
store[Value.new(:objkey2)] = true
store[Value.new(:objkey2)].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = false
+ store[Value.new(:objkey2)].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = false
store.fetch(Value.new(:objkey2), true).should == false
end
@@ -12796,10 +35096,22 @@
store[Value.new(:objkey1)] = "strval1"
store[Value.new(:objkey1)].should == "strval1"
store[Value.new(:objkey1)] = "strval2"
store[Value.new(:objkey1)].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = "strval1"
+ store[Value.new(:objkey1)].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = "strval1"
store.fetch(Value.new(:objkey1), "strval2").should == "strval1"
end
@@ -12847,10 +35159,22 @@
store[Value.new(:objkey2)] = "strval1"
store[Value.new(:objkey2)].should == "strval1"
store[Value.new(:objkey2)] = "strval2"
store[Value.new(:objkey2)].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = "strval1"
+ store[Value.new(:objkey2)].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = "strval1"
store.fetch(Value.new(:objkey2), "strval2").should == "strval1"
end
@@ -12898,10 +35222,22 @@
store[Value.new(:objkey1)] = "strval2"
store[Value.new(:objkey1)].should == "strval2"
store[Value.new(:objkey1)] = "strval1"
store[Value.new(:objkey1)].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = "strval2"
+ store[Value.new(:objkey1)].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = "strval2"
store.fetch(Value.new(:objkey1), "strval1").should == "strval2"
end
@@ -12949,10 +35285,22 @@
store[Value.new(:objkey2)] = "strval2"
store[Value.new(:objkey2)].should == "strval2"
store[Value.new(:objkey2)] = "strval1"
store[Value.new(:objkey2)].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = "strval2"
+ store[Value.new(:objkey2)].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = "strval2"
store.fetch(Value.new(:objkey2), "strval1").should == "strval2"
end
@@ -13300,10 +35648,22 @@
store[Value.new(:objkey1)] = {"hashval1"=>["array1", 1]}
store[Value.new(:objkey1)].should == {"hashval1"=>["array1", 1]}
store[Value.new(:objkey1)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey1)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[Value.new(:objkey1)].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = {"hashval1"=>["array1", 1]}
store.fetch(Value.new(:objkey1), {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -13351,10 +35711,22 @@
store[Value.new(:objkey2)] = {"hashval1"=>["array1", 1]}
store[Value.new(:objkey2)].should == {"hashval1"=>["array1", 1]}
store[Value.new(:objkey2)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey2)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[Value.new(:objkey2)].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = {"hashval1"=>["array1", 1]}
store.fetch(Value.new(:objkey2), {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -13402,10 +35774,22 @@
store[Value.new(:objkey1)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey1)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey1)] = {"hashval1"=>["array1", 1]}
store[Value.new(:objkey1)].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[Value.new(:objkey1)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(Value.new(:objkey1), {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -13453,10 +35837,22 @@
store[Value.new(:objkey2)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey2)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[Value.new(:objkey2)] = {"hashval1"=>["array1", 1]}
store[Value.new(:objkey2)].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[Value.new(:objkey2)].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch(Value.new(:objkey2), {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -13804,10 +36200,22 @@
store[Value.new(:objkey1)] = Value.new(:objval1)
store[Value.new(:objkey1)].should == Value.new(:objval1)
store[Value.new(:objkey1)] = Value.new(:objval2)
store[Value.new(:objkey1)].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = Value.new(:objval1)
+ store[Value.new(:objkey1)].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = Value.new(:objval1)
store.fetch(Value.new(:objkey1), Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -13855,10 +36263,22 @@
store[Value.new(:objkey2)] = Value.new(:objval1)
store[Value.new(:objkey2)].should == Value.new(:objval1)
store[Value.new(:objkey2)] = Value.new(:objval2)
store[Value.new(:objkey2)].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = Value.new(:objval1)
+ store[Value.new(:objkey2)].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = Value.new(:objval1)
store.fetch(Value.new(:objkey2), Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -13906,10 +36326,22 @@
store[Value.new(:objkey1)] = Value.new(:objval2)
store[Value.new(:objkey1)].should == Value.new(:objval2)
store[Value.new(:objkey1)] = Value.new(:objval1)
store[Value.new(:objkey1)].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[Value.new(:objkey1)] = value).should equal(value)
+ store[Value.new(:objkey1)].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey1).freeze
+ store[key] = Value.new(:objval2)
+ store[Value.new(:objkey1)].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey1)] = Value.new(:objval2)
store.fetch(Value.new(:objkey1), Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -13957,10 +36389,22 @@
store[Value.new(:objkey2)] = Value.new(:objval2)
store[Value.new(:objkey2)].should == Value.new(:objval2)
store[Value.new(:objkey2)] = Value.new(:objval1)
store[Value.new(:objkey2)].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[Value.new(:objkey2)] = value).should equal(value)
+ store[Value.new(:objkey2)].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = Value.new(:objkey2).freeze
+ store[key] = Value.new(:objval2)
+ store[Value.new(:objkey2)].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[Value.new(:objkey2)] = Value.new(:objval2)
store.fetch(Value.new(:objkey2), Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -14309,10 +36753,22 @@
store[{"hashkey1"=>"hashkey2"}].should == 0
store[{"hashkey1"=>"hashkey2"}] = nil
store[{"hashkey1"=>"hashkey2"}].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = 0
+ store[{"hashkey1"=>"hashkey2"}].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[{"hashkey3"=>"hashkey4"}] = 0
store[{"hashkey3"=>"hashkey4"}].should == 0
store.load({"hashkey3"=>"hashkey4"}).should == 0
end
@@ -14349,10 +36805,22 @@
store[{"hashkey3"=>"hashkey4"}].should == 0
store[{"hashkey3"=>"hashkey4"}] = nil
store[{"hashkey3"=>"hashkey4"}].should == nil
end
+ it 'stores frozen values' do
+ value = 0.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 0
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = 0
+ store[{"hashkey3"=>"hashkey4"}].should == 0
+ end
+
it 'writes values to keys that like a Hash' do
store[{"hashkey1"=>"hashkey2"}] = nil
store[{"hashkey1"=>"hashkey2"}].should == nil
store.load({"hashkey1"=>"hashkey2"}).should == nil
end
@@ -14389,10 +36857,22 @@
store[{"hashkey1"=>"hashkey2"}].should == nil
store[{"hashkey1"=>"hashkey2"}] = 0
store[{"hashkey1"=>"hashkey2"}].should == 0
end
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = nil
+ store[{"hashkey1"=>"hashkey2"}].should == nil
+ end
+
it 'writes values to keys that like a Hash' do
store[{"hashkey3"=>"hashkey4"}] = nil
store[{"hashkey3"=>"hashkey4"}].should == nil
store.load({"hashkey3"=>"hashkey4"}).should == nil
end
@@ -14428,10 +36908,22 @@
store[{"hashkey3"=>"hashkey4"}] = nil
store[{"hashkey3"=>"hashkey4"}].should == nil
store[{"hashkey3"=>"hashkey4"}] = 0
store[{"hashkey3"=>"hashkey4"}].should == 0
end
+
+ it 'stores frozen values' do
+ value = nil.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == nil
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = nil
+ store[{"hashkey3"=>"hashkey4"}].should == nil
+ end
end
#################### persist_hashkey_nilvalue ####################
shared_examples_for 'persist_hashkey_nilvalue' do
@@ -14712,10 +37204,22 @@
store[{"hashkey1"=>"hashkey2"}] = 41
store[{"hashkey1"=>"hashkey2"}].should == 41
store[{"hashkey1"=>"hashkey2"}] = -12
store[{"hashkey1"=>"hashkey2"}].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = 41
+ store[{"hashkey1"=>"hashkey2"}].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = 41
store.fetch({"hashkey1"=>"hashkey2"}, -12).should == 41
end
@@ -14763,10 +37267,22 @@
store[{"hashkey3"=>"hashkey4"}] = 41
store[{"hashkey3"=>"hashkey4"}].should == 41
store[{"hashkey3"=>"hashkey4"}] = -12
store[{"hashkey3"=>"hashkey4"}].should == -12
end
+
+ it 'stores frozen values' do
+ value = 41.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 41
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = 41
+ store[{"hashkey3"=>"hashkey4"}].should == 41
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = 41
store.fetch({"hashkey3"=>"hashkey4"}, -12).should == 41
end
@@ -14814,10 +37330,22 @@
store[{"hashkey1"=>"hashkey2"}] = -12
store[{"hashkey1"=>"hashkey2"}].should == -12
store[{"hashkey1"=>"hashkey2"}] = 41
store[{"hashkey1"=>"hashkey2"}].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = -12
+ store[{"hashkey1"=>"hashkey2"}].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = -12
store.fetch({"hashkey1"=>"hashkey2"}, 41).should == -12
end
@@ -14865,10 +37393,22 @@
store[{"hashkey3"=>"hashkey4"}] = -12
store[{"hashkey3"=>"hashkey4"}].should == -12
store[{"hashkey3"=>"hashkey4"}] = 41
store[{"hashkey3"=>"hashkey4"}].should == 41
end
+
+ it 'stores frozen values' do
+ value = -12.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == -12
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = -12
+ store[{"hashkey3"=>"hashkey4"}].should == -12
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = -12
store.fetch({"hashkey3"=>"hashkey4"}, 41).should == -12
end
@@ -14910,10 +37450,990 @@
@store = nil
store[{"hashkey3"=>"hashkey4"}].should == -12
end
end
+#################### null_hashkey_numbervalue ####################
+
+shared_examples_for 'null_hashkey_numbervalue' do
+ it 'reads from keys like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ store.load({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.clear.should equal(store)
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey1"=>"hashkey2"}, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey1"=>"hashkey2"}
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey1"=>"hashkey2"}, options).should be_false
+ store.load({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.fetch({"hashkey1"=>"hashkey2"}, 42, options).should == 42
+ store.fetch({"hashkey1"=>"hashkey2"}, options) { 42 }.should == 42
+ store.delete({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey1"=>"hashkey2"}, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ store.load({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 123.456
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.clear.should equal(store)
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey3"=>"hashkey4"}, 123.456).should == 123.456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey3"=>"hashkey4"}
+ value = 123.456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey3"=>"hashkey4"}, options).should be_false
+ store.load({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.fetch({"hashkey3"=>"hashkey4"}, 42, options).should == 42
+ store.fetch({"hashkey3"=>"hashkey4"}, options) { 42 }.should == 42
+ store.delete({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey3"=>"hashkey4"}, 123.456, options).should == 123.456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ store.load({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.clear.should equal(store)
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey1"=>"hashkey2"}, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey1"=>"hashkey2"}
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey1"=>"hashkey2"}, options).should be_false
+ store.load({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.fetch({"hashkey1"=>"hashkey2"}, 42, options).should == 42
+ store.fetch({"hashkey1"=>"hashkey2"}, options) { 42 }.should == 42
+ store.delete({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey1"=>"hashkey2"}, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ store.load({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = -98.7
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.clear.should equal(store)
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey3"=>"hashkey4"}, -98.7).should == -98.7
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey3"=>"hashkey4"}
+ value = -98.7
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey3"=>"hashkey4"}, options).should be_false
+ store.load({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.fetch({"hashkey3"=>"hashkey4"}, 42, options).should == 42
+ store.fetch({"hashkey3"=>"hashkey4"}, options) { 42 }.should == 42
+ store.delete({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey3"=>"hashkey4"}, -98.7, options).should == -98.7
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ store.load({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.clear.should equal(store)
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey1"=>"hashkey2"}, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey1"=>"hashkey2"}
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey1"=>"hashkey2"}, options).should be_false
+ store.load({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.fetch({"hashkey1"=>"hashkey2"}, 42, options).should == 42
+ store.fetch({"hashkey1"=>"hashkey2"}, options) { 42 }.should == 42
+ store.delete({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey1"=>"hashkey2"}, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ store.load({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 340282366920938463463374607431768211456
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.clear.should equal(store)
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey3"=>"hashkey4"}, 340282366920938463463374607431768211456).should == 340282366920938463463374607431768211456
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey3"=>"hashkey4"}
+ value = 340282366920938463463374607431768211456
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey3"=>"hashkey4"}, options).should be_false
+ store.load({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.fetch({"hashkey3"=>"hashkey4"}, 42, options).should == 42
+ store.fetch({"hashkey3"=>"hashkey4"}, options) { 42 }.should == 42
+ store.delete({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey3"=>"hashkey4"}, 340282366920938463463374607431768211456, options).should == 340282366920938463463374607431768211456
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ store.load({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey1"=>"hashkey2"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey1"=>"hashkey2"}, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey1"=>"hashkey2"}
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey1"=>"hashkey2"}, options).should be_false
+ store.load({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.fetch({"hashkey1"=>"hashkey2"}, 42, options).should == 42
+ store.fetch({"hashkey1"=>"hashkey2"}, options) { 42 }.should == 42
+ store.delete({"hashkey1"=>"hashkey2"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey1"=>"hashkey2"}, 33, options).should == 33
+ end
+
+ it 'reads from keys like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ store.load({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'guarantees that the same value is returned when setting a key' do
+ value = 33
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ end
+
+ it 'returns false from key? if a key is not available' do
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'returns nil from delete if a value for a key does not exist' do
+ store.delete({"hashkey3"=>"hashkey4"}).should be_nil
+ end
+
+ it 'removes all keys from the store with clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'fetches a key with a default value with fetch, if the key is not available' do
+ store.fetch({"hashkey3"=>"hashkey4"}, 33).should == 33
+ end
+
+ it 'fetches a key with a block with fetch, if the key is not available' do
+ key = {"hashkey3"=>"hashkey4"}
+ value = 33
+ store.fetch(key) do |k|
+ k.should equal(key)
+ value
+ end.should equal(value)
+ end
+
+ it 'accepts frozen options' do
+ options = {:option1 => 1, :options2 => 2}
+ options.freeze
+ store.key?({"hashkey3"=>"hashkey4"}, options).should be_false
+ store.load({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.fetch({"hashkey3"=>"hashkey4"}, 42, options).should == 42
+ store.fetch({"hashkey3"=>"hashkey4"}, options) { 42 }.should == 42
+ store.delete({"hashkey3"=>"hashkey4"}, options).should be_nil
+ store.clear(options).should equal(store)
+ store.store({"hashkey3"=>"hashkey4"}, 33, options).should == 33
+ end
+end
+
+#################### store_hashkey_numbervalue ####################
+
+shared_examples_for 'store_hashkey_numbervalue' do
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ store.load({"hashkey1"=>"hashkey2"}).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.key?({"hashkey1"=>"hashkey2"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ store.load({"hashkey1"=>"hashkey2"}).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.clear.should equal(store)
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.delete({"hashkey1"=>"hashkey2"}).should == 123.456
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = 123.456
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.fetch({"hashkey1"=>"hashkey2"}, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ unaltered = 'unaltered'
+ store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ store.load({"hashkey3"=>"hashkey4"}).should == 123.456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.key?({"hashkey3"=>"hashkey4"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 123.456
+ store.store({"hashkey3"=>"hashkey4"}, value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ store.load({"hashkey3"=>"hashkey4"}).should == 123.456
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.clear.should equal(store)
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.delete({"hashkey3"=>"hashkey4"}).should == 123.456
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ end
+
+ it 'stores frozen values' do
+ value = 123.456.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = 123.456
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.fetch({"hashkey3"=>"hashkey4"}, -98.7).should == 123.456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ unaltered = 'unaltered'
+ store.fetch({"hashkey3"=>"hashkey4"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ store.load({"hashkey1"=>"hashkey2"}).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.key?({"hashkey1"=>"hashkey2"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ store.load({"hashkey1"=>"hashkey2"}).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.clear.should equal(store)
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.delete({"hashkey1"=>"hashkey2"}).should == -98.7
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = -98.7
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.fetch({"hashkey1"=>"hashkey2"}, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ unaltered = 'unaltered'
+ store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ store.load({"hashkey3"=>"hashkey4"}).should == -98.7
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.key?({"hashkey3"=>"hashkey4"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = -98.7
+ store.store({"hashkey3"=>"hashkey4"}, value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ store.load({"hashkey3"=>"hashkey4"}).should == -98.7
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.clear.should equal(store)
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.delete({"hashkey3"=>"hashkey4"}).should == -98.7
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ end
+
+ it 'stores frozen values' do
+ value = -98.7.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = -98.7
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.fetch({"hashkey3"=>"hashkey4"}, 123.456).should == -98.7
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ unaltered = 'unaltered'
+ store.fetch({"hashkey3"=>"hashkey4"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ store.load({"hashkey1"=>"hashkey2"}).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.key?({"hashkey1"=>"hashkey2"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ store.load({"hashkey1"=>"hashkey2"}).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.clear.should equal(store)
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.delete({"hashkey1"=>"hashkey2"}).should == 340282366920938463463374607431768211456
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.fetch({"hashkey1"=>"hashkey2"}, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ store.load({"hashkey3"=>"hashkey4"}).should == 340282366920938463463374607431768211456
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.key?({"hashkey3"=>"hashkey4"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 340282366920938463463374607431768211456
+ store.store({"hashkey3"=>"hashkey4"}, value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ store.load({"hashkey3"=>"hashkey4"}).should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.clear.should equal(store)
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.delete({"hashkey3"=>"hashkey4"}).should == 340282366920938463463374607431768211456
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ end
+
+ it 'stores frozen values' do
+ value = 340282366920938463463374607431768211456.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.fetch({"hashkey3"=>"hashkey4"}, 33).should == 340282366920938463463374607431768211456
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ unaltered = 'unaltered'
+ store.fetch({"hashkey3"=>"hashkey4"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ store.load({"hashkey1"=>"hashkey2"}).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.key?({"hashkey1"=>"hashkey2"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store({"hashkey1"=>"hashkey2"}, value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ store.load({"hashkey1"=>"hashkey2"}).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ store[{"hashkey3"=>"hashkey4"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.delete({"hashkey1"=>"hashkey2"}).should == 33
+ store.key?({"hashkey1"=>"hashkey2"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = 33
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.fetch({"hashkey1"=>"hashkey2"}, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ unaltered = 'unaltered'
+ store.fetch({"hashkey1"=>"hashkey2"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+
+ it 'writes values to keys that like a Hash' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ store.load({"hashkey3"=>"hashkey4"}).should == 33
+ end
+
+ it 'returns true from key? if a key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.key?({"hashkey3"=>"hashkey4"}).should be_true
+ end
+
+ it 'stores values with #store' do
+ value = 33
+ store.store({"hashkey3"=>"hashkey4"}, value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ store.load({"hashkey3"=>"hashkey4"}).should == 33
+ end
+
+ it 'stores values after clear' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.clear.should equal(store)
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ store[{"hashkey1"=>"hashkey2"}].should be_nil
+ end
+
+ it 'removes and returns a value from the backing store via delete if it exists' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.delete({"hashkey3"=>"hashkey4"}).should == 33
+ store.key?({"hashkey3"=>"hashkey4"}).should be_false
+ end
+
+ it 'overwrites existing values' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'stores frozen values' do
+ value = 33.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = 33
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ end
+ it 'fetches a key with a default value with fetch, if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.fetch({"hashkey3"=>"hashkey4"}, 340282366920938463463374607431768211456).should == 33
+ end
+
+ it 'does not run the block in fetch if the key is available' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ unaltered = 'unaltered'
+ store.fetch({"hashkey3"=>"hashkey4"}) { unaltered = 'altered' }
+ unaltered.should == 'unaltered'
+ end
+end
+
+#################### persist_hashkey_numbervalue ####################
+
+shared_examples_for 'persist_hashkey_numbervalue' do
+ it 'persists values' do
+ store[{"hashkey1"=>"hashkey2"}] = 123.456
+ store.close
+ @store = nil
+ store[{"hashkey1"=>"hashkey2"}].should == 123.456
+ end
+
+ it 'persists values' do
+ store[{"hashkey3"=>"hashkey4"}] = 123.456
+ store.close
+ @store = nil
+ store[{"hashkey3"=>"hashkey4"}].should == 123.456
+ end
+
+ it 'persists values' do
+ store[{"hashkey1"=>"hashkey2"}] = -98.7
+ store.close
+ @store = nil
+ store[{"hashkey1"=>"hashkey2"}].should == -98.7
+ end
+
+ it 'persists values' do
+ store[{"hashkey3"=>"hashkey4"}] = -98.7
+ store.close
+ @store = nil
+ store[{"hashkey3"=>"hashkey4"}].should == -98.7
+ end
+
+ it 'persists values' do
+ store[{"hashkey1"=>"hashkey2"}] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[{"hashkey1"=>"hashkey2"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[{"hashkey3"=>"hashkey4"}] = 340282366920938463463374607431768211456
+ store.close
+ @store = nil
+ store[{"hashkey3"=>"hashkey4"}].should == 340282366920938463463374607431768211456
+ end
+
+ it 'persists values' do
+ store[{"hashkey1"=>"hashkey2"}] = 33
+ store.close
+ @store = nil
+ store[{"hashkey1"=>"hashkey2"}].should == 33
+ end
+
+ it 'persists values' do
+ store[{"hashkey3"=>"hashkey4"}] = 33
+ store.close
+ @store = nil
+ store[{"hashkey3"=>"hashkey4"}].should == 33
+ end
+end
+
#################### null_hashkey_booleanvalue ####################
shared_examples_for 'null_hashkey_booleanvalue' do
it 'reads from keys like a Hash' do
store[{"hashkey1"=>"hashkey2"}].should be_nil
@@ -15160,10 +38680,22 @@
store[{"hashkey1"=>"hashkey2"}] = true
store[{"hashkey1"=>"hashkey2"}].should == true
store[{"hashkey1"=>"hashkey2"}] = false
store[{"hashkey1"=>"hashkey2"}].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = true
+ store[{"hashkey1"=>"hashkey2"}].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = true
store.fetch({"hashkey1"=>"hashkey2"}, false).should == true
end
@@ -15211,10 +38743,22 @@
store[{"hashkey3"=>"hashkey4"}] = true
store[{"hashkey3"=>"hashkey4"}].should == true
store[{"hashkey3"=>"hashkey4"}] = false
store[{"hashkey3"=>"hashkey4"}].should == false
end
+
+ it 'stores frozen values' do
+ value = true.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == true
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = true
+ store[{"hashkey3"=>"hashkey4"}].should == true
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = true
store.fetch({"hashkey3"=>"hashkey4"}, false).should == true
end
@@ -15262,10 +38806,22 @@
store[{"hashkey1"=>"hashkey2"}] = false
store[{"hashkey1"=>"hashkey2"}].should == false
store[{"hashkey1"=>"hashkey2"}] = true
store[{"hashkey1"=>"hashkey2"}].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = false
+ store[{"hashkey1"=>"hashkey2"}].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = false
store.fetch({"hashkey1"=>"hashkey2"}, true).should == false
end
@@ -15313,10 +38869,22 @@
store[{"hashkey3"=>"hashkey4"}] = false
store[{"hashkey3"=>"hashkey4"}].should == false
store[{"hashkey3"=>"hashkey4"}] = true
store[{"hashkey3"=>"hashkey4"}].should == true
end
+
+ it 'stores frozen values' do
+ value = false.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == false
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = false
+ store[{"hashkey3"=>"hashkey4"}].should == false
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = false
store.fetch({"hashkey3"=>"hashkey4"}, true).should == false
end
@@ -15608,10 +39176,22 @@
store[{"hashkey1"=>"hashkey2"}] = "strval1"
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
store[{"hashkey1"=>"hashkey2"}] = "strval2"
store[{"hashkey1"=>"hashkey2"}].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = "strval1"
+ store[{"hashkey1"=>"hashkey2"}].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = "strval1"
store.fetch({"hashkey1"=>"hashkey2"}, "strval2").should == "strval1"
end
@@ -15659,10 +39239,22 @@
store[{"hashkey3"=>"hashkey4"}] = "strval1"
store[{"hashkey3"=>"hashkey4"}].should == "strval1"
store[{"hashkey3"=>"hashkey4"}] = "strval2"
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
end
+
+ it 'stores frozen values' do
+ value = "strval1".freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == "strval1"
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = "strval1"
+ store[{"hashkey3"=>"hashkey4"}].should == "strval1"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = "strval1"
store.fetch({"hashkey3"=>"hashkey4"}, "strval2").should == "strval1"
end
@@ -15710,10 +39302,22 @@
store[{"hashkey1"=>"hashkey2"}] = "strval2"
store[{"hashkey1"=>"hashkey2"}].should == "strval2"
store[{"hashkey1"=>"hashkey2"}] = "strval1"
store[{"hashkey1"=>"hashkey2"}].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = "strval2"
+ store[{"hashkey1"=>"hashkey2"}].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = "strval2"
store.fetch({"hashkey1"=>"hashkey2"}, "strval1").should == "strval2"
end
@@ -15761,10 +39365,22 @@
store[{"hashkey3"=>"hashkey4"}] = "strval2"
store[{"hashkey3"=>"hashkey4"}].should == "strval2"
store[{"hashkey3"=>"hashkey4"}] = "strval1"
store[{"hashkey3"=>"hashkey4"}].should == "strval1"
end
+
+ it 'stores frozen values' do
+ value = "strval2".freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == "strval2"
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = "strval2"
+ store[{"hashkey3"=>"hashkey4"}].should == "strval2"
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = "strval2"
store.fetch({"hashkey3"=>"hashkey4"}, "strval1").should == "strval2"
end
@@ -16112,10 +39728,22 @@
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>["array1", 1]}
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>["array1", 1]}
store[{"hashkey1"=>"hashkey2"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey1"=>"hashkey2"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>["array1", 1]}
store.fetch({"hashkey1"=>"hashkey2"}, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -16163,10 +39791,22 @@
store[{"hashkey3"=>"hashkey4"}] = {"hashval1"=>["array1", 1]}
store[{"hashkey3"=>"hashkey4"}].should == {"hashval1"=>["array1", 1]}
store[{"hashkey3"=>"hashkey4"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval1"=>["array1", 1]}.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == {"hashval1"=>["array1", 1]}
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = {"hashval1"=>["array1", 1]}
+ store[{"hashkey3"=>"hashkey4"}].should == {"hashval1"=>["array1", 1]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = {"hashval1"=>["array1", 1]}
store.fetch({"hashkey3"=>"hashkey4"}, {"hashval3"=>["array2", {"hashval4"=>42}]}).should == {"hashval1"=>["array1", 1]}
end
@@ -16214,10 +39854,22 @@
store[{"hashkey1"=>"hashkey2"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey1"=>"hashkey2"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey1"=>"hashkey2"}] = {"hashval1"=>["array1", 1]}
store[{"hashkey1"=>"hashkey2"}].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[{"hashkey1"=>"hashkey2"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch({"hashkey1"=>"hashkey2"}, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -16265,10 +39917,22 @@
store[{"hashkey3"=>"hashkey4"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
store[{"hashkey3"=>"hashkey4"}] = {"hashval1"=>["array1", 1]}
store[{"hashkey3"=>"hashkey4"}].should == {"hashval1"=>["array1", 1]}
end
+
+ it 'stores frozen values' do
+ value = {"hashval3"=>["array2", {"hashval4"=>42}]}.freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = {"hashval3"=>["array2", {"hashval4"=>42}]}
+ store[{"hashkey3"=>"hashkey4"}].should == {"hashval3"=>["array2", {"hashval4"=>42}]}
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = {"hashval3"=>["array2", {"hashval4"=>42}]}
store.fetch({"hashkey3"=>"hashkey4"}, {"hashval1"=>["array1", 1]}).should == {"hashval3"=>["array2", {"hashval4"=>42}]}
end
@@ -16616,10 +40280,22 @@
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval2)
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = Value.new(:objval1)
+ store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
store.fetch({"hashkey1"=>"hashkey2"}, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -16667,10 +40343,22 @@
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval1)
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval1)
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval2)
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval1).freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = Value.new(:objval1)
+ store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval1)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval1)
store.fetch({"hashkey3"=>"hashkey4"}, Value.new(:objval2)).should == Value.new(:objval1)
end
@@ -16718,10 +40406,22 @@
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval2)
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval2)
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval1)
store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval1)
end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[{"hashkey1"=>"hashkey2"}] = value).should equal(value)
+ store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey1"=>"hashkey2"}.freeze
+ store[key] = Value.new(:objval2)
+ store[{"hashkey1"=>"hashkey2"}].should == Value.new(:objval2)
+ end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey1"=>"hashkey2"}] = Value.new(:objval2)
store.fetch({"hashkey1"=>"hashkey2"}, Value.new(:objval1)).should == Value.new(:objval2)
end
@@ -16768,9 +40468,21 @@
it 'overwrites existing values' do
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval2)
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval1)
store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval1)
+ end
+
+ it 'stores frozen values' do
+ value = Value.new(:objval2).freeze
+ (store[{"hashkey3"=>"hashkey4"}] = value).should equal(value)
+ store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
+ end
+
+ it 'stores frozen keys' do
+ key = {"hashkey3"=>"hashkey4"}.freeze
+ store[key] = Value.new(:objval2)
+ store[{"hashkey3"=>"hashkey4"}].should == Value.new(:objval2)
end
it 'fetches a key with a default value with fetch, if the key is available' do
store[{"hashkey3"=>"hashkey4"}] = Value.new(:objval2)
store.fetch({"hashkey3"=>"hashkey4"}, Value.new(:objval1)).should == Value.new(:objval2)
end