Sha256: 3b4a8dd2a52c5e0340119bc932edd15b634f64504e68746e8a1dc1ff8204fcea
Contents?: true
Size: 1.33 KB
Versions: 7
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe Zemanta::Cache::Disk do let(:cache) { Zemanta::Cache::Disk } let(:storage) { cache.new } describe "#initialize" do it "creates directory to store files if one doesnt exist" do temp_dir = Pathname.new('spec/temp_dir') temp_dir.delete if temp_dir.exist? temp_dir.should_not exist cache.new(temp_dir) temp_dir.should exist temp_dir.delete end it "uses tmp/db as default directory" do storage.db.should == Pathname.new('tmp/db') end end describe "#[key]" do it "returns nil if key doesnt exist" do storage['non-existing-key'].should be_nil end it "returns stored value if the key exists" do value = "string data" storage['key'] = value storage['key'].should == value end end describe "#[key]=" do let(:key) { 'some-key' } let(:value) { 'text-value' } it "creates new file for specified key" do Pathname.new(storage.db.join(key)).delete if storage.db.join(key).exist? Pathname.new(storage.db.join(key)).should_not exist storage[key] = value Pathname.new(storage.db.join(key)).should exist end it "overwrites existing file for specified key" do storage[key] = value storage[key] = "new value" storage[key].should == "new value" end end end
Version data entries
7 entries across 7 versions & 1 rubygems