Sha256: f6ec4a23f3ddf9312016aff63304fb34c3b23b81934f72e27c60e1e78a4b8e04

Contents?: true

Size: 1.8 KB

Versions: 12

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

module Liquid
  module Rails
    describe ContentForTag, type: :tag do
      it 'content_for and yield with non-quoted key' do
        Liquid::Template.parse(%|{% content_for not_authorized0 %}alert('You are not authorized to do that!');{% endcontent_for %}|).render(context)

        expect_template_result(%|{% yield not_authorized0 %}|, "alert('You are not authorized to do that!');")
      end

      it 'content_for and yield with quoted key' do
        Liquid::Template.parse(%|{% content_for 'not_authorized1' %}alert('You are not authorized to do that!');{% endcontent_for %}|).render(context)

        expect_template_result(%|{% yield 'not_authorized1' %}|, "alert('You are not authorized to do that!');")
      end

      it 'invokes content_for with the same identifier multiple times' do
        Liquid::Template.parse(%|{% content_for 'not_authorized2' %}alert('You are not authorized to do that 1!');{% endcontent_for %}|).render(context)
        Liquid::Template.parse(%|{% content_for 'not_authorized2' %}alert('You are not authorized to do that 2!');{% endcontent_for %}|).render(context)

        expect_template_result(%|{% yield 'not_authorized2' %}|, "alert('You are not authorized to do that 1!');alert('You are not authorized to do that 2!');")
      end

      it 'invokes content_for with the same identifier multiple times and flush' do
        Liquid::Template.parse(%|{% content_for 'not_authorized3' %}alert('You are not authorized to do that 1!');{% endcontent_for %}|).render(context)
        Liquid::Template.parse(%|{% content_for 'not_authorized3' flush true %}alert('You are not authorized to do that 2!');{% endcontent_for %}|).render(context)

        expect_template_result(%|{% yield 'not_authorized3' %}|, "alert('You are not authorized to do that 2!');")
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
liquid-rails-0.2.0 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid-rails-0.2.0.beta1 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid-rails-0.1.4 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails5-0.5.0 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails5-0.4.0 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails5-0.3.0 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails5-0.2.1 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails5-0.1.5 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid4-rails-0.2.0 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid-rails-0.1.3 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid-rails-0.1.2 spec/lib/liquid-rails/tags/content_for_tag_spec.rb
liquid-rails-0.1.1 spec/lib/liquid-rails/tags/content_for_tag_spec.rb