Sha256: d18db25103d23b25cb8cc7d49ef87854fac5d30d75ecb561bac50fc5ab62899b

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe Locomotive::Steam::Liquid::Tags::Section do

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

  subject { render_template(source, context).strip }

  describe 'image_picker field' do

    let(:source) { <<-EOF
      {% if image is present %}
        We've got an image!
      {% else %}
        Nope
      {% endif %}
  EOF
    }

    let(:assigns)   { { 'image' => Locomotive::Steam::Liquid::Drops::SectionImagePickerField.new(image) } }

    context 'the image is nil' do

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

    end

    context 'the image is an empty string' do

      let(:image) { '' }
      it { is_expected.to eq 'Nope' }

    end

    context 'the image is an url' do

      let(:image) { 'https://cdn.somewhere.net/images/banner.png' }
      it { is_expected.to eq "We've got an image!" }

    end

  end

  describe 'link field' do

    let(:source) { <<-EOF
      {% if link is present %}
        We've got a link!
      {% else %}
        Nope
      {% endif %}
  EOF
    }

    let(:assigns) { { 'link' => Locomotive::Steam::Liquid::Drops::SectionUrlField.new(url) } }

    context 'the link is nil' do

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

    end

    context 'the link is an empty string' do

      let(:url) { '' }
      it { is_expected.to eq 'Nope' }

    end

    context 'the link is an url' do

      let(:url) { 'https://www.locomotivecms.com' }
      it { is_expected.to eq "We've got a link!" }

    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.7.1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.7.0 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.6.1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.6.0 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.5.3 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.5.2 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.5.1 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.5.0 spec/integration/liquid/tags/section_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/integration/liquid/tags/section_spec.rb