Sha256: 27caf05ae5f8cd0d08fb1dc4f16fe325261341c2da6be43771e80fe9b0cc1b38

Contents?: true

Size: 1.07 KB

Versions: 37

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

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

describe Locomotive::Steam::SnippetRepository do

  let(:snippets)    { [{ name: 'Simple', slug: 'simple', template_path: { en: 'simple.yml' } }] }
  let(:locale)      { :en }
  let(:site)        { instance_double('Site', _id: 1, default_locale: :en, locales: [:en, :fr]) }
  let(:adapter)     { Locomotive::Steam::FilesystemAdapter.new(nil) }
  let(:repository)  { described_class.new(adapter, site, locale) }

  before do
    allow(adapter).to receive(:collection).and_return(snippets)
    adapter.cache = NoCacheStore.new
  end

  describe '#by_slug' do

    let(:name) { nil }
    subject { repository.by_slug(name) }

    it { is_expected.to eq nil }

    context 'existing snippet' do

      let(:name) { 'simple' }
      it { expect(subject.class).to eq Locomotive::Steam::Snippet }
      it { expect(subject.name).to eq 'Simple' }
      it { expect(subject[:template_path][:en]).to eq 'simple.yml' }
      it { expect(subject[:template_path][:fr]).to eq 'simple.yml' }

    end

  end

end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.1 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc10 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc9 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc8 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc6 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc4 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc3 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc2 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.rc1 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.3 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.2 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.beta.1 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.3 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.2 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.1 spec/unit/repositories/snippet_repository_spec.rb
locomotivecms_steam-1.0.0.pre.alpha spec/unit/repositories/snippet_repository_spec.rb