Sha256: dad9d90b355c889e891e821877820efae0fd430744fa7c841fcc1bbec34f7586

Contents?: true

Size: 1.04 KB

Versions: 51

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Liquid::Tags::FetchPage do

  let(:source)        { "{% fetch_page about_us as a_page %}{{ a_page.title }}" }
  let(:assigns)       { {} }
  let(:repositories)  { Locomotive::Steam::Services.build_instance.repositories }
  let(:context)       { ::Liquid::Context.new(assigns, {}, { repositories: repositories }) }

  let(:page)  { instance_double('Page', to_liquid: { 'title' => 'About Us' }) }
  before      { allow(repositories.page).to receive(:by_handle).and_return(page) }

  subject { render_template(source, context) }

  describe 'validating syntax' do

    it { expect { subject }.not_to raise_exception }

    describe 'raises an error if the syntax is incorrect' do
      let(:source) { "{% fetch_page 'about_us' %}{{ a_page.title }}" }
      it { expect { subject }.to raise_exception(::SyntaxError) }
    end

  end

  describe 'rendering' do

    it { is_expected.to eq 'About Us' }

    describe 'no page found' do

      let(:page) { nil }
      it { is_expected.to eq '' }

    end

  end

end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.7.1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.7.0 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.6.1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.6.0 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.3 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.2 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0.rc0 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0.beta3 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.4.1 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.4.0 spec/unit/liquid/tags/fetch_page_spec.rb
locomotivecms_steam-1.4.0.rc2 spec/unit/liquid/tags/fetch_page_spec.rb