### Start Example Project Locally Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Run these commands to start the example project in this repository locally. This allows you to preview your documentation changes. ```sh cd example bundle install bundle exec middleman server ``` -------------------------------- ### Ruby RSpec Example Source: https://github.com/alphagov/tech-docs-gem/blob/main/example/source/code.html.md This snippet demonstrates a basic RSpec test structure for a ContentItem class, including setup with fixtures. ```ruby # Example comment to check syntax highlighting for comments RSpec.describe ContentItem do subject { described_class.new(base_path) } let(:base_path) { "/search/news-and-communications" } let(:finder_content_item) { news_and_communications } let(:news_and_communications) { JSON.parse(File.read(Rails.root.join("features", "fixtures", "news_and_communications.json"))) } RSpec.describe "as_hash" do it "returns a content item as a hash" do expect(subject.as_hash).to eql(finder_content_item) end end end ``` -------------------------------- ### Start Jasmine Test Server Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Run this command to start the Jasmine test server for JavaScript tests. Access the results in your browser. ```sh bundle exec rake jasmine:server ``` -------------------------------- ### Short Ruby RSpec Example Source: https://github.com/alphagov/tech-docs-gem/blob/main/example/source/code.html.md A minimal RSpec test structure for a ContentItem class. ```ruby RSpec.describe ContentItem do end ``` -------------------------------- ### Single Page Table of Contents Example Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Generates a table of contents for the current page, limiting the depth to 2 levels. This is useful for creating navigation within a single document. ```erb <% wrap_layout :core do content_for :sidebar do <%= single_page_table_of_contents(html, max_level: 2) %> end end %> ``` -------------------------------- ### Multi Page Table of Contents Example Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Generates a table of contents for multiple pages within a Middleman site. It includes options to specify resources, the current page, site configuration, and whether to include child resources. ```erb <% wrap_layout :core do content_for :sidebar do <%= multi_page_table_of_contents(sitemap.resources, current_page, config, yield, include_child_resources: true) %> end end %> ``` -------------------------------- ### Add Local Tech Docs Gem to Gemfile Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Point your website's Gemfile to your local checkout of the tech-docs-gem to see how your changes affect your website. ```ruby gem 'govuk_tech_docs', path: '../tech-docs-gem' ``` -------------------------------- ### Run All Linting and Tests Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Use this command to run both the linting and tests for the Ruby and JavaScript code within the gem. ```sh bundle exec rake ``` -------------------------------- ### Run Jasmine Tests in CI Mode Source: https://github.com/alphagov/tech-docs-gem/blob/main/README.md Execute this command to run the JavaScript tests and view the results directly in your terminal. ```sh bundle exec rake jasmine:ci ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.