Sha256: d587aba98d4a990fb6e6aa735f583135b0da2372790fc5ff94c9405e9c1a534c

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  module Liquid
    module Tags
      RSpec.describe GistTag, 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 = "{% gist %}"

          expect { ::Liquid::Template.parse(content).render(context) }.to(
            raise_error(::Liquid::SyntaxError)
          )
        end

        it "returns gist" do
          gist = "9bbaf7332bff1042c2d83fc88683b9df"
          result = ::Liquid::Template.parse("{% gist '#{gist}' %}")
                                     .render(context)

          expect(result).to include("https://gist.github.com/#{gist}.js")
        end

        it "returns gist with file" do
          gist = "9bbaf7332bff1042c2d83fc88683b9df"
          file = "hello.rb"
          content = "{% gist '#{gist}' file: '#{file}' %}"
          result = ::Liquid::Template.parse(content).render(context)

          expect(result)
            .to include("https://gist.github.com/#{gist}.js?file=#{file}")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
archangel-0.3.0 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.8 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.7 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.6 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.5 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.4 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.3 spec/lib/archangel/liquid/tags/gist_tag_spec.rb
archangel-0.0.2 spec/lib/archangel/liquid/tags/gist_tag_spec.rb