Sha256: 11a368476b0ecb22aee12d8cb92c690a8177aa395778616cbbc5b020463e0a5a

Contents?: true

Size: 1022 Bytes

Versions: 9

Compression:

Stored size: 1022 Bytes

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)  { nil }
  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 '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

9 entries across 9 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.rc4 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc3 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc2 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.rc1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.pre.beta.3 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.pre.beta.2 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.pre.beta.1 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.3 spec/unit/decorators/template_decorator_spec.rb
locomotivecms_steam-1.0.0.pre.alpha.2 spec/unit/decorators/template_decorator_spec.rb