Sha256: 25059a0d914c18f2f2fd847f06227147e98900b31db20d58fd9f1ae51c5c7a62

Contents?: true

Size: 1.53 KB

Versions: 26

Compression:

Stored size: 1.53 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

describe "Friendly::StorageFactory" do
  before do
    @doc_table       = stub
    @doc_table_klass = stub(:new => @doc_table)
    @index           = stub
    @index_klass     = stub(:new => @index)
    @cache_by_id     = stub
    @cache_klass     = stub(:cache_for => @cache_by_id)
    @factory         = Friendly::StorageFactory.new(@doc_table_klass, @index_klass, 
                                                      @cache_klass)
  end

  describe "creating a document table" do
    before do
      @klass    = stub
      @returned = @factory.document_table(@klass)
    end

    it "returns the result of the constructor" do
      @returned.should == @doc_table
    end

    it "passes along the arguments to the constructor" do
      @doc_table_klass.should have_received(:new).with(@klass)
    end
  end

  describe "creating an index table" do
    before do
      @klass    = stub
      @returned = @factory.index(@klass)
    end

    it "returns the result of the constructor" do
      @returned.should == @index
    end

    it "passes along the arguments to the constructor" do
      @index_klass.should have_received(:new).with(@klass)
    end
  end

  describe "creating an id cache table" do
    before do
      @klass    = stub
      @returned = @factory.cache(@klass, [:id])
    end

    it "delegates to Cache.for" do
      @returned.should == @cache_by_id
    end

    it "supplies arguments to Cache" do
      @cache_klass.should have_received(:cache_for).with(@klass, [:id])
    end
  end
end

Version data entries

26 entries across 26 versions & 7 rubygems

Version Path
ihoka-friendly-0.8.0.pre spec/unit/storage_factory_spec.rb
ihoka-friendly-0.7.1.2 spec/unit/storage_factory_spec.rb
ihoka-friendly-0.7.1.1 spec/unit/storage_factory_spec.rb
ihoka-friendly-0.7.1 spec/unit/storage_factory_spec.rb
ihoka-friendly-0.7.0 spec/unit/storage_factory_spec.rb
friendly-0.6.0 spec/unit/storage_factory_spec.rb
honkster-friendly-0.5.3 spec/unit/storage_factory_spec.rb
honkster-friendly-0.5.2 spec/unit/storage_factory_spec.rb
honkster-friendly-0.5.1 spec/unit/storage_factory_spec.rb
wayne-friendly-0.5.1 spec/unit/storage_factory_spec.rb
wego-friendly-0.5.1 spec/unit/storage_factory_spec.rb
arunthampi-friendly-0.5.1 spec/unit/storage_factory_spec.rb
friendly_postgres-0.5.1 spec/unit/storage_factory_spec.rb
friendly-0.5.1 spec/unit/storage_factory_spec.rb
friendly-0.5.0 spec/unit/storage_factory_spec.rb
friendly_postgres-0.4.5 spec/unit/storage_factory_spec.rb
friendly-0.4.5 spec/unit/storage_factory_spec.rb
friendly-0.4.4 spec/unit/storage_factory_spec.rb
friendly_postgres-0.4.3 spec/unit/storage_factory_spec.rb
friendly-0.4.3 spec/unit/storage_factory_spec.rb