<commit_before>require 'spec_helper'

feature "Showing a contact page" do

  it "renders a contact page" do
    path = '/government/organisations/hm-revenue-customs/contact/annual-tax-on-enveloped-dwellings-ated'

    content_store_has_item(path, read_content_store_fixture('hmrc_ated'), 15.minutes.to_i)

    visit(path)

    expect(page).to have_content("Annual Tax on Enveloped Dwellings")
    expect(page.response_headers["Cache-Control"]).to eq("max-age=900, public")
    expect_links("#global-breadcrumb", {
      "Home" => "/",
      "HM Revenue & Customs" => "/government/organisations/hm-revenue-customs",
      "Contact HMRC" => "/government/organisations/hm-revenue-customs/contact",
    })
    expect_links(".quick-links", {
      "Annual Tax on Enveloped Dwellings" => "http://www.hmrc.gov.uk/ated/index.htm",
    })
    expect_links(".related-links", {
      "Annual tax on enveloped dwellings contact" => "http://www.hmrc.gov.uk/ated/contact.htm",
      "Another contact" => "http://www.hmrc.gov.uk/ated/another.htm"
    })    
  end

  it "should 404 for a non-existent item in the content-store" do
    path = '/government/organisations/hm-revenue-customs/contact/bear-tax'

    content_store_does_not_have_item(path)

    visit(path)
    expect(page.status_code).to eq(404)
  end

  def expect_links(selector, links)
    within selector do
      found_links = page.all("li a").map(&:text).map(&:strip)
      expect(found_links).to eq(links.keys)

      links.each do |link_text, href|
        expect(page).to have_link(link_text, :href => href)
      end
    end
  end<commit_msg>Whitespace.<commit_after>require 'spec_helper'

feature "Showing a contact page" do

  it "renders a contact page" do
    path = '/government/organisations/hm-revenue-customs/contact/annual-tax-on-enveloped-dwellings-ated'

    content_store_has_item(path, read_content_store_fixture('hmrc_ated'), 15.minutes.to_i)

    visit(path)

    expect(page).to have_content("Annual Tax on Enveloped Dwellings")
    expect(page.response_headers["Cache-Control"]).to eq("max-age=900, public")
    expect_links("#global-breadcrumb", {
      "Home" => "/",
      "HM Revenue & Customs" => "/government/organisations/hm-revenue-customs",
      "Contact HMRC" => "/government/organisations/hm-revenue-customs/contact",
    })
    expect_links(".quick-links", {
      "Annual Tax on Enveloped Dwellings" => "http://www.hmrc.gov.uk/ated/index.htm",
    })
    expect_links(".related-links", {
      "Annual tax on enveloped dwellings contact" => "http://www.hmrc.gov.uk/ated/contact.htm",
      "Another contact" => "http://www.hmrc.gov.uk/ated/another.htm"
    })
  end

  it "should 404 for a non-existent item in the content-store" do
    path = '/government/organisations/hm-revenue-customs/contact/bear-tax'

    content_store_does_not_have_item(path)

    visit(path)
    expect(page.status_code).to eq(404)
  end

  def expect_links(selector, links)
    within selector do
      found_links = page.all("li a").map(&:text).map(&:strip)
      expect(found_links).to eq(links.keys)

      links.each do |link_text, href|
        expect(page).to have_link(link_text, :href => href)
      end
    end
  end
{'fraction_non_alphanumeric': 0.1445141065830721, 'fraction_numerical': 0.006896551724137931, 'mean_word_length': 3.5070621468926553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346169', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1067, 'n_words': 193}