Sha256: c560deff7408b8113bdadae94db252750b3993b2fe317bc44650d5a3f8cdbde8

Contents?: true

Size: 945 Bytes

Versions: 9

Compression:

Stored size: 945 Bytes

Contents

require 'spec_helper'

describe Zemanta::Fetcher::Cache do
  describe "for set storage" do
    before :each do
      Zemanta.configure { |config| config.cache_storage = {} }
      Zemanta::Fetcher::Cache.new("key").save("test data")
    end

    after :all do
      Zemanta.configure { |config| config.cache_storage = Zemanta::Configuration::NullStorage.new }
    end

    it "saves the data to cache if it's saved first time" do
      Zemanta.config.cache_storage.size.should == 1
    end

    it "doesn't save the data if same key was used before" do
      Zemanta::Fetcher::Cache.new("key").save("test data")
      Zemanta.config.cache_storage.size.should == 1
    end

    it "fetch returns nil if no key in cache" do
      Zemanta::Fetcher::Cache.new("another_key").fetch.should be_nil
    end

    it "fetch returns the value data if key is present" do
      Zemanta::Fetcher::Cache.new("key").fetch.should == "test data"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zemanta_client-0.0.9 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.8 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.7 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.6 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.5 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.4 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.3 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.2 spec/zemanta/fetcher/cache_spec.rb
zemanta_client-0.0.1 spec/zemanta/fetcher/cache_spec.rb