Sha256: 9b4ba77873d597a444d588895853c8b07a004880097385c6a9c1042217b023ed
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zemanta_client-0.0.2 | spec/zemanta/cache/disk_spec.rb |
zemanta_client-0.0.1 | spec/zemanta/cache/disk_spec.rb |