Sha256: 78dd018bab3971113d80bdeadf88bb8ba713f8f077ebf470d26f0c8c0d6524ff

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require "spec_helper"

class GithubGistDummyClass
  include Nanoc::Toolbox::Helpers::GithubGist
end

describe Nanoc::Toolbox::Helpers::GithubGist do
  subject { GithubGistDummyClass.new }
  it {should respond_to(:gist) }

  describe "#gist" do
    context "without a filename" do
      it "takes at list a Gist ID as parameter" do
        lambda{ subject.gist }.should raise_error
      end

      it "ensures that Gist ID is an Integer or a hex number" do
        lambda{ subject.gist('123') }.should_not raise_error
        lambda{ subject.gist(12345) }.should_not raise_error
        lambda{ subject.gist('decafbad123') }.should_not raise_error
        lambda{ subject.gist('+supercool+xxx') }.should raise_error
      end

      it "returns the script tag for a gist" do
        src = "https://gist.github.com/123.js"
        subject.gist(123).should eq %Q{<script src="#{src}"></script>}
      end
    end

    context "with a filename" do
      it "ensures that the file name is an String" do
        lambda{ subject.gist(12345, 12345) }.should raise_error
        lambda{ subject.gist(12345, 'index.html') }.should_not raise_error
      end

      it "returns the script tag for a specific file if specified" do
        src = "https://gist.github.com/123.js?file=README.md"
        subject.gist(123, "README.md").should eq %Q{<script src="#{src}"></script>}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-toolbox-0.2.1 spec/helpers/github_gist_spec.rb