Sha256: 98114b0a5ddf8fd3c1dd9e95ec205c6083f26578ded377b160472a1d59942ef9

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe(Jekyll::Gist::GistTag) do
  let(:doc) { doc_with_content(content) }
  let(:content)  { "{% gist #{gist} %}" }
  let(:output) do
    doc.content = content
    doc.output  = Jekyll::Renderer.new(doc.site, doc).run
  end

  context "simple gist" do
    let(:gist) { 358471 }

    it "produces the correct script tag" do
      expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
    end
  end

  context "private gist" do

    context "when valid" do
      let(:gist) { "mattr-/24081a1d93d2898ecf0f" }

      it "produces the correct script tag" do
        expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
      end
    end

    context "with file specified" do
      let(:gist)     { "mattr-/24081a1d93d2898ecf0f" }
      let(:filename) { "myfile.ext" }
      let(:content)  { "{% gist #{gist} #{filename} %}" }

      it "produces the correct script tag" do
        expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>/)
      end
    end

    context "when invalid" do
      let(:gist) { "mattr-24081a1d93d2898ecf0f" }

      it "raises an error" do
        expect(->{ output }).to raise_error
      end
    end

  end

  context "no gist id present" do
    let(:gist) { "" }

    it "raises an error" do
      expect(->{ output }).to raise_error
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-gist-1.0.0 spec/gist_tag_spec.rb
jekyll-gist-1.0.0.rc1 spec/gist_tag_spec.rb