Sha256: eeed83b89366b8788f4e6f1e67700be3147dd6ef3d12acbccf68ad503cc16539

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 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(ArgumentError)
      end

      it "ensures that Gist ID is an Integer" do
        lambda{ subject.gist('abc') }.should raise_error(ArgumentError)
        lambda{ subject.gist('123') }.should raise_error(ArgumentError)
        lambda{ subject.gist(12345) }.should_not raise_error(ArgumentError)
      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(ArgumentError)
        lambda{ subject.gist(12345, 'index.html') }.should_not raise_error(ArgumentError)
      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

4 entries across 4 versions & 1 rubygems

Version Path
nanoc-toolbox-0.2.0 spec/helpers/github_gist_spec.rb
nanoc-toolbox-0.1.3 spec/helpers/github_gist_spec.rb
nanoc-toolbox-0.1.2 spec/helpers/github_gist_spec.rb
nanoc-toolbox-0.1.1 spec/helpers/github_gist_spec.rb