Sha256: 2d4a4dc317c4bfa8c395f7a70b2a6136e659138159ca118ad18243012ad2afd4

Contents?: true

Size: 922 Bytes

Versions: 54

Compression:

Stored size: 922 Bytes

Contents

require 'spec_helper'

require_relative '../../../lib/locomotive/steam/adapters/memory.rb'

describe Locomotive::Steam::MemoryAdapter do

  let(:collection)  { [OpenStruct.new(name: 'Hello world')] }
  let(:mapper)      { instance_double('Mapper', name: :test) }
  let(:scope)       { instance_double('Scope', locale: nil) }
  let(:adapter)     { Locomotive::Steam::MemoryAdapter.new(collection) }

  before { allow(mapper).to receive(:to_entity) { |arg| arg } }

  describe '#all' do

    subject { adapter.all(mapper, scope) }
    it { expect(subject.size).to eq 1 }

  end

  describe '#query' do

    let(:block) { -> (_) { where(name: 'Hello world') } }
    subject { adapter.query(mapper, scope, &block) }
    it { expect(subject.size).to eq 1 }

    context 'another syntax' do

      let(:block) { -> (_) { where(k(:name, :in) => ['Hello world']) } }
      it { expect(subject.size).to eq 1 }

    end

  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.7.1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.7.0 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.6.1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.6.0 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.3 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.2 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0.rc0 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0.beta3 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.4.1 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.4.0 spec/unit/adapters/memory_adapter_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/adapters/memory_adapter_spec.rb