Sha256: a027b134e4658d312df0538f9439fce2a1fbc3143e7a7154105269ca3680a586
Contents?: true
Size: 1.74 KB
Versions: 8
Compression:
Stored size: 1.74 KB
Contents
# frozen_string_literal: true require "rails_helper" module Archangel module Liquid module Tags RSpec.describe WidgetTag, type: :liquid_tag do let(:site) { create(:site) } let(:context) do ::Liquid::Context.new({ "site" => site }, {}, view: view) end it "raises error with invalid syntax" do content = "{% widget %}" expect { ::Liquid::Template.parse(content).render(context) }.to( raise_error(::Liquid::SyntaxError) ) end it "returns widget content" do widget = create(:widget, site: site) result = ::Liquid::Template.parse("{% widget '#{widget.slug}' %}") .render(context) expect(result).to include("<p>Content of the widget</p>") end it "returns widget content" do widget = create(:widget, site: site) result = ::Liquid::Template.parse("{% widget '#{widget.slug}' %}") .render(context) expect(result).to include("<p>Content of the widget</p>") end it "returns widget content with template" do template = create(:template, :partial, site: site) widget = create(:widget, site: site, template: template) result = ::Liquid::Template.parse("{% widget '#{widget.slug}' %}") .render(context) expect(result).to include("<p>Content of the widget</p>") end it "returns nothing for unknown widget" do result = ::Liquid::Template.parse("{% widget 'unknown_widget' %}") .render(context) expect(result).to eq("") end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems