Sha256: 09687d191832c0b084c43250270e7d05470ad19717fc1328c310ff6f34682e0a

Contents?: true

Size: 1.81 KB

Versions: 26

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

require 'sqlite3'

describe Picky::Backends::SQLite::Value do

  context 'hash-based indexes' do
    let(:db) { described_class.new 'spec/temp/some/other/cache/path/to/file' }

    describe 'dump' do
      it 'forwards to the given hash' do
        hash = double :hash

        db.should_receive(:dump_sqlite).once.with hash

        db.dump hash
      end
    end

    describe 'dump_sqlite' do
      let(:client) { double :client }
      before(:each) do
        db.stub :db => client
      end
      it 'initializes the client' do
        client.stub :execute

        db.should_receive(:db).exactly(4).times.with no_args

        db.dump_sqlite Hash.new
      end
      it 'executes something' do
        db.stub :lazily_initialize_client

        client.should_receive(:execute).at_least(1).times

        db.dump_sqlite Hash.new
      end
      it 'inserts keys and values' do
        # db.stub :db
        client.stub :execute # We only want to test the insert statements.

        client.should_receive(:execute).once.with 'insert into key_value values (?,?)', 'a', '[1,2,3]'
        client.should_receive(:execute).once.with 'insert into key_value values (?,?)', 'b', '[4,5,6]'

        db.dump_sqlite :a => [1,2,3], :b => [4,5,6]
      end
    end

    describe 'load' do
      it 'returns a copy of itself' do
        db.load.should == db
      end
    end

    describe 'empty' do
      it 'returns the container that is used for indexing' do
        db.empty.should == {}
      end
    end

    describe 'initial' do
      it 'is correct' do
        db.initial.should == {}
      end
    end

    describe 'to_s' do
      it 'returns the cache path with the default file extension' do
        db.to_s.should == 'Picky::Backends::SQLite::Value(spec/temp/some/other/cache/path/to/file.sqlite3)'
      end
    end
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
picky-4.30.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.29.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.28.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.27.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.27.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.26.2 spec/lib/backends/sqlite/value_spec.rb
picky-4.26.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.26.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.25.3 spec/lib/backends/sqlite/value_spec.rb
picky-4.25.2 spec/lib/backends/sqlite/value_spec.rb
picky-4.25.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.25.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.24.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.23.2 spec/lib/backends/sqlite/value_spec.rb
picky-4.23.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.23.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.22.0 spec/lib/backends/sqlite/value_spec.rb
picky-4.21.2 spec/lib/backends/sqlite/value_spec.rb
picky-4.21.1 spec/lib/backends/sqlite/value_spec.rb
picky-4.21.0 spec/lib/backends/sqlite/value_spec.rb