Sha256: 501f598ad05eb6bc08b3d8fa31182be4f8344b9476c9b915e75059c0bd64ef89

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Picky::Backends::SQLite::DirectlyManipulable do

  let(:client) { double :client }
  let(:backend) { double :backend, client: client, namespace: 'some:namespace' }
  let(:array) do
    array = [1,2]
    described_class.make backend, array, 'some:key'
    array
  end

  context 'stubbed backend' do
    before(:each) do
      backend.stub :[]
    end
    it 'calls the right client method' do
      backend.should_receive(:[]=).once.with 'some:key', [1,2,3]

      array << 3
    end
    it 'calls the right client method' do
      backend.should_receive(:[]=).once.with 'some:key', [3,1,2]

      array.unshift 3
    end
    it 'calls the right client method' do
      backend.should_receive(:[]=).once.with 'some:key', [2]

      array.delete 1
    end
    it 'calls the right client method' do
      client.should_receive(:zrem).never

      array.delete 5
    end
  end

  context 'stubbed client/backend' do
    before(:each) do
      backend.stub :[]=
    end
    it 'behaves like an ordinary Array' do
      array << 3

      array.should == [1,2,3]
    end
    it 'behaves like an ordinary Array' do
      array.unshift 3

      array.should == [3,1,2]
    end
    it 'behaves like an ordinary Array' do
      array.delete 1

      array.should == [2]
    end
    it 'behaves like an ordinary Array' do
      array.delete 5

      array.should == [1,2]
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-4.22.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.21.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.21.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.21.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.20.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.20.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.20.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.19.7 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.19.6 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.19.5 spec/lib/backends/sqlite/directly_manipulable_spec.rb