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.31.3 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.31.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.31.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.31.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.30.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.29.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.28.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.27.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.27.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.26.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.26.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.26.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.25.3 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.25.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.25.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.25.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.24.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.23.2 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.23.1 spec/lib/backends/sqlite/directly_manipulable_spec.rb
picky-4.23.0 spec/lib/backends/sqlite/directly_manipulable_spec.rb