Sha256: 5fdfacf289bf008f4a654163e9f36875850b5ae4049bb400a6f55e16fe946997

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"

describe Autodoc::Documents do
  describe "#render_toc" do
    before do
      documents.append(context)
    end

    let(:documents) do
      Autodoc::Documents.new
    end

    let(:context) do
      mock = double(example: example, request: request)
      mock.stub(clone: mock)
      mock
    end

    let(:example) do
      double(file_path: file_path, full_description: full_description)
    end

    let(:file_path) do
      "spec/requests/recipes.md"
    end

    let(:request) do
      double(method: method)
    end

    let(:method) do
      "GET"
    end

    context "with GET /recipes spec" do
      let(:full_description) do
        "Recipe #{method} /recipes returns recipes"
      end

      let(:file_path) do
        "./spec/requests/recipes_spec.rb"
      end

      it "includes links to recipes.md" do
        toc = documents.send(:render_toc)
        toc.should include("[recipes.md](recipes.md)")
        toc.should include("[GET /recipes](recipes.md#get-recipes)")
      end
    end

    context "with GET /admin/recipes spec" do
      let(:full_description) do
        "Admin::Recipe #{method} /admin/recipes returns recipes for administrator"
      end

      let(:file_path) do
        "./spec/requests/admin/recipes_spec.rb"
      end

      it "includes links to admin/recipes.md" do
        toc = documents.send(:render_toc)
        toc.should include("[admin/recipes.md](admin/recipes.md)")
        toc.should include("[GET /admin/recipes](admin/recipes.md#get-adminrecipes)")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
autodoc-0.3.6 spec/autodoc/documents_spec.rb
autodoc-0.3.5 spec/autodoc/documents_spec.rb
autodoc-0.3.4 spec/autodoc/documents_spec.rb
autodoc-0.3.3 spec/autodoc/documents_spec.rb