Sha256: 4ec084c8effae9de6e9cfcb2f02cedf41778f88162daa001626b0ca423099528

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Liquid::Tags::Snippet do

  let(:services)  { Locomotive::Steam::Services.build_instance(nil) }
  let(:finder)    { services.snippet_finder }
  let(:snippet)   { instance_double('Snippet', template: nil, :template= => nil, liquid_source: 'built by NoCoffee') }
  let(:source)    { 'Locomotive {% include footer %}' }

  before { allow(finder).to receive(:find).and_return(snippet) }

  describe 'parsing' do

    let(:page)      { instance_double('Page') }
    let!(:listener) { Liquid::SimpleEventsListener.new }
    let(:options)   { { page: page, snippet_finder: finder, parser: services.liquid_parser } }

    let!(:template) { parse_template(source, options) }

    it { expect(listener.event_names.first).to eq 'steam.parse.include' }

    # describe 'with an editable_element inside', pending: true do

    #   let(:snippet) { instance_double('Snippet', source: '{% editable_text company %}built by NoCoffee{% endeditable_text %}') }

    #   it { expect(listener.events.size).to eq 2 }

    # end

  end

  describe 'rendering' do

    let(:context) { ::Liquid::Context.new({}, {}, { services: services }) }

    subject { render_template(source, context) }

    it { is_expected.to eq 'Locomotive built by NoCoffee' }

    context 'rendering error (action) found in the snippet' do

      let(:snippet) { instance_double('Snippet', template: nil, :template= => nil, liquid_source: '{% action "Hello world" %}a.b(+}{% endaction %}') }

      it 'raises ParsingRenderingError' do
        expect { subject }.to raise_exception(Locomotive::Steam::ParsingRenderingError)
      end

    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotivecms_steam-1.5.0.beta3 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.4.1 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.4.0 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.4.0.rc1 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.4.0.pre.rc.1 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.3.0 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.3.0.rc2 spec/unit/liquid/tags/snippet_spec.rb
locomotivecms_steam-1.3.0.rc1 spec/unit/liquid/tags/snippet_spec.rb