Sha256: e11b4d4bdef49623d8d899746c905ef19d90bafd146aef9a999c92dafeab1daa
Contents?: true
Size: 1.69 KB
Versions: 31
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' require_relative '../../../lib/locomotive/steam/adapters/filesystem.rb' describe Locomotive::Steam::FilesystemAdapter do let(:mapper) { instance_double('Mapper', name: :test) } let(:scope) { instance_double('Scope', site: site, locale: nil, to_key: 'key') } let(:adapter) { Locomotive::Steam::FilesystemAdapter.new(nil) } describe '#key' do subject { adapter.key(:title, :in) } it { is_expected.to eq 'title.in' } end describe '#query' do let(:collection) { [OpenStruct.new(site_id: 42, name: 'Hello world')] } before do allow(mapper).to receive(:to_entity) { |arg| arg } allow(adapter).to receive(:collection).and_return(collection) end subject { adapter.query(mapper, scope) { where(name: 'Hello world') } } context 'not scoped by a site' do let(:site) { nil } it { expect(subject.first.name).to eq 'Hello world' } end context 'scoped by a site' do let(:site) { instance_double('Site', _id: 42) } it { expect(subject.first.name).to eq 'Hello world' } context 'unknown site id' do let(:site) { instance_double('Site', _id: 1) } it { expect(subject.first).to eq nil } end end end describe '#inc' do let(:entity) { OpenStruct.new(name: 'My post', views: 41) } subject { adapter.inc(mapper, entity, :views) } it { expect(subject.views).to eq 42 } describe 'by an amount different from 1' do subject { adapter.inc(mapper, entity, :views, 3) } it { expect(subject.views).to eq 44 } end end describe '#make_id' do let(:id) { '42' } subject { adapter.make_id(id) } it { is_expected.to eq('42') } end end
Version data entries
31 entries across 31 versions & 1 rubygems