Sha256: fbb8eca3b7241d9f6e70863f4e41cbdb2f143c63746b45a782ef3ea31d099899

Contents?: true

Size: 1.21 KB

Versions: 13

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Decorators::TemplateDecorator do

  let(:template_path)   { 'template.liquid' }
  let(:page)            { instance_double('Page', localized_attributes: [], template_path: template_path) }
  let(:locale)          { 'fr' }
  let(:default_locale)  { 'en' }
  let(:decorated)       { described_class.new(page, locale, default_locale) }

  describe '#liquid_source' do

    let(:content) { 'Lorem ipsum' }

    before { allow(File).to receive(:read).and_return(content) }

    subject { decorated.liquid_source.strip }

    it { is_expected.to eq 'Lorem ipsum' }

    context 'Raw template' do

      let(:page) { instance_double('Page', localized_attributes: [:source], source: { en: 'Lorem ipsum [EN]', fr: '' }) }

      it { is_expected.to eq 'Lorem ipsum [EN]' }

    end

    context 'HAML file' do

      let(:template_path) { 'template.liquid.haml' }
      let(:content) { '%p Lorem ipsum' }

      it { is_expected.to eq '<p>Lorem ipsum</p>' }

      context 'incorrect HAML syntax' do

        let(:content) { "foo\n  %p TEST" }

        it 'raises an error' do
          expect { subject }.to raise_error Locomotive::Steam::RenderError
        end

      end

    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.2.0.beta1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.1.1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.1.0 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.1.0.rc3 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.1.0.rc2 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.1.0.rc1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc10 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc9 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc8 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc6 spec/unit/decorators/template_decorator_spec.rb