Skip to content

Commit

Permalink
Review: tidy up structure of tests
Browse files Browse the repository at this point in the history
- one describe block to describe what you're testing
- context blocks to specify the conditions of the tests
  • Loading branch information
richardTowers committed Mar 12, 2021
1 parent 43e3620 commit a0c9bfd
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions spec/govuk_tech_docs/tech_docs_html_renderer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,41 @@ def hello_world
MARKDOWN
}

it "sets tab index to 0" do
expect(output).to include('<pre tabindex="0">')
end
context "without syntax highlighting" do
let(:processor) {
Redcarpet::Markdown.new(described_class.new(context: context), fenced_code_blocks: true)
}

it "sets tab index to 0" do
expect(output).to include('<pre tabindex="0">')
end

it "renders the code without syntax highlighting" do
expect(output).to include("def hello_world")
expect(output).to include('puts "hello world"')
expect(output).to include("end")
it "renders the code without syntax highlighting" do
expect(output).to include("def hello_world")
expect(output).to include('puts "hello world"')
expect(output).to include("end")
end
end

describe "with syntax highlighting" do

context "with syntax highlighting" do
let(:processor) {
renderer_class = described_class.clone.tap do |c|
c.send :include, Middleman::Syntax::RedcarpetCodeRenderer
end
Redcarpet::Markdown.new(renderer_class.new(context: context), tables: true, fenced_code_blocks: true)
Redcarpet::Markdown.new(renderer_class.new(context: context), fenced_code_blocks: true)
}

describe "#render a code block" do
it "sets tab index to 0" do
expect(output).to include('<pre class=" ruby" tabindex="0">')
end
it "sets tab index to 0" do
expect(output).to include('<pre class=" ruby" tabindex="0">')
end

it "renders the code with syntax highlighting" do
expect(output).to include("def</span>")
expect(output).to include("hello_world</span>")
expect(output).to include("puts</span>")
expect(output).to include('"hello world"</span>')
expect(output).to include("end</span>")
end
it "renders the code with syntax highlighting" do
expect(output).to include("def</span>")
expect(output).to include("hello_world</span>")
expect(output).to include("puts</span>")
expect(output).to include('"hello world"</span>')
expect(output).to include("end</span>")
end
end
end
Expand Down

0 comments on commit a0c9bfd

Please sign in to comment.