Skip to content

Commit

Permalink
Remove assert_has_component_govspeak method
Browse files Browse the repository at this point in the history
- since it's now just has_text, no need for it to be a separate method
- update tests
  • Loading branch information
andysellick committed Jun 5, 2018
1 parent 2e3adf6 commit 3cafef2
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/integration/answer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AnswerTest < ActionDispatch::IntegrationTest
test "renders title and body" do
setup_and_visit_content_item('answer')
assert page.has_text?(@content_item["title"])
assert_has_component_govspeak("Bydd angen cod cychwyn arnoch i ddechrau defnyddio’r holl wasanaethau hyn, ac eithrio TAW. Anfonir hwn atoch cyn pen saith diwrnod gwaith ar ôl i chi gofrestru. Os ydych chi’n byw dramor, gall gymryd hyd at 21 diwrnod i gyrraedd.")
assert page.has_text?("Bydd angen cod cychwyn arnoch i ddechrau defnyddio’r holl wasanaethau hyn, ac eithrio TAW. Anfonir hwn atoch cyn pen saith diwrnod gwaith ar ôl i chi gofrestru. Os ydych chi’n byw dramor, gall gymryd hyd at 21 diwrnod i gyrraedd.")
end

test "related links are rendered" do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/case_study_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CaseStudyTest < ActionDispatch::IntegrationTest

within ".gem-c-notice" do
assert page.has_text?('This case study was withdrawn'), "is withdrawn"
assert_has_component_govspeak("We’ve withdrawn this case study and published newer")
assert page.has_text?("We’ve withdrawn this case study and published newer")
assert page.has_css?("time[datetime='#{@content_item['withdrawn_notice']['withdrawn_at']}']")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/consultation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ConsultationTest < ActionDispatch::IntegrationTest
assert page.has_text?("4pm on 20 April 2016 to 10:45pm on 13 July 2016")

within '.consultation-outcome-detail' do
assert_has_component_govspeak(@content_item["details"]["final_outcome_detail"])
assert page.has_text?(@content_item["details"]["final_outcome_detail"])
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/contact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ContactTest < ActionDispatch::IntegrationTest
test "online forms are rendered" do
setup_and_visit_content_item('contact')

assert_has_component_govspeak("If HMRC needs to contact you about anything confidential they’ll reply by phone or post.")
assert_has_component_govspeak("Contact HMRC to report suspicious activity in relation to smuggling, customs, excise and VAT fraud.")
assert page.has_text?("If HMRC needs to contact you about anything confidential they’ll reply by phone or post.")
assert page.has_text?("Contact HMRC to report suspicious activity in relation to smuggling, customs, excise and VAT fraud.")

assert page.has_css?("h2#online-forms-title")
first_contact_form_link = @content_item["details"]["contact_form_links"].first
Expand Down
2 changes: 1 addition & 1 deletion test/integration/detailed_guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
assert page.has_css?('title', text: "[Withdrawn]", visible: false)

assert page.has_text?('This guidance was withdrawn'), "is withdrawn"
assert_has_component_govspeak("This information has been archived as it is now out of date. For current information please go to")
assert page.has_text?("This information has been archived as it is now out of date. For current information please go to")
assert page.has_css?("time[datetime='#{@content_item['withdrawn_notice']['withdrawn_at']}']")
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/document_collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest

test "renders body when provided" do
setup_and_visit_content_item('document_collection_with_body')
assert_has_component_govspeak("Each regime page provides a current list of asset freeze targets designated by the United Nations (UN), European Union and United Kingdom, under legislation relating to current financial sanctions regimes.")
assert page.has_text?("Each regime page provides a current list of asset freeze targets designated by the United Nations (UN), European Union and United Kingdom, under legislation relating to current financial sanctions regimes.")
end

test "renders contents with link to each collection group" do
Expand Down Expand Up @@ -144,7 +144,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest

within ".gem-c-notice" do
assert page.has_text?('This collection was withdrawn'), "is withdrawn"
assert_has_component_govspeak("This information is now out of date.")
assert page.has_text?("This information is now out of date.")
assert page.has_css?("time[datetime='#{@content_item['withdrawn_notice']['withdrawn_at']}']")
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/fatality_notice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
'should have image with ministry-of-defence source with alt text'
)

assert_has_component_govspeak("Colley served nearly all of his military and administrative career in British South Africa, but he played a significant part in the Second Anglo-Afghan War as military secretary and then private secretary to the governor-general of India, Lord Lytton. The war began in November 1878 and ended in May 1879 with the Treaty of Gandamak.")
assert page.has_text?("Colley served nearly all of his military and administrative career in British South Africa, but he played a significant part in the Second Anglo-Afghan War as military secretary and then private secretary to the governor-general of India, Lord Lytton. The war began in November 1878 and ended in May 1879 with the Treaty of Gandamak.")

within(".content-bottom-margin .app-c-published-dates") do
assert page.has_content?("Published 27 February 1881")
Expand Down Expand Up @@ -79,7 +79,7 @@ class FatalityNoticeTest < ActionDispatch::IntegrationTest
within ".gem-c-notice" do
assert_text("This fatality notice was withdrawn on 14 September 2016")

assert_has_component_govspeak("This content is not factually correct. For current information please go to")
assert page.has_text?("This content is not factually correct. For current information please go to")
end
end
end
2 changes: 1 addition & 1 deletion test/integration/help_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class HelpPageTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item('help_page')

assert page.has_text?(@content_item["title"])
assert_has_component_govspeak("GOV.UK puts small files (known as ‘cookies’) onto your computer to collect information about how you browse the site.")
assert page.has_text?("GOV.UK puts small files (known as ‘cookies’) onto your computer to collect information about how you browse the site.")
assert_has_published_dates(@content_item["last_updated"])
end
end
6 changes: 1 addition & 5 deletions test/integration/html_publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["links"]["organisations"][0]["title"])
end

assert_has_component_govspeak_html_publication(@content_item["details"]["body"])
assert page.has_text?("The Environment Agency will normally put any responses it receives on the public register. This includes your name and contact details. Tell us if you don’t want your response to be public.")
end

test "html publications with meta data" do
Expand Down Expand Up @@ -77,10 +77,6 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest
assert page.has_css?("#wrapper.direction-rtl"), "has .direction-rtl class on #wrapper element"
end

def assert_has_component_govspeak_html_publication(content)
assert_has_component_govspeak("The Environment Agency will normally put any responses it receives on the public register. This includes your name and contact details. Tell us if you don’t want your response to be public.")
end

def assert_has_component_organisation_logo_with_brand(brand, index = 1)
within("li.organisation-logo:nth-of-type(#{index}) #{shared_component_selector('organisation_logo')}") do
assert_equal brand, JSON.parse(page.text).fetch("organisation").fetch("brand")
Expand Down
6 changes: 3 additions & 3 deletions test/integration/publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PublicationTest < ActionDispatch::IntegrationTest
assert page.has_text?(@content_item["description"])

within '[aria-labelledby="details-title"]' do
assert_has_component_govspeak("Installation name: Leeming Biogas Facility")
assert page.has_text?("Installation name: Leeming Biogas Facility")
end
end

Expand All @@ -35,7 +35,7 @@ class PublicationTest < ActionDispatch::IntegrationTest
test "renders a govspeak block for attachments" do
setup_and_visit_content_item('publication')
within '[aria-labelledby="documents-title"]' do
assert_has_component_govspeak("Permit: Veolia ES (UK) Limited")
assert page.has_text?("Permit: Veolia ES (UK) Limited")
end
end

Expand All @@ -45,7 +45,7 @@ class PublicationTest < ActionDispatch::IntegrationTest

within ".gem-c-notice" do
assert page.has_text?('This publication was withdrawn'), "is withdrawn"
assert_has_component_govspeak("guidance for keepers of sheep, goats and pigs")
assert page.has_text?("guidance for keepers of sheep, goats and pigs")
assert page.has_css?("time[datetime='#{@content_item['withdrawn_notice']['withdrawn_at']}']")
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/specialist_document_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest

assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("The gyroplane began to move forward against the brakes before sufficient rotor rpm had been achieved for takeoff.")
assert page.has_text?("The gyroplane began to move forward against the brakes before sufficient rotor rpm had been achieved for takeoff.")
end

test "returns example for residential tribunal decision" do
setup_and_visit_content_item('residential-property-tribunal-decision')

assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")
assert page.has_text?("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")
end

test "renders from in publisher metadata" do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/speech_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SpeechTest < ActionDispatch::IntegrationTest

assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("These subjects are of course crucial. But in the UK, only 1 woman to every 7 men works in science, technology, engineering and maths. We need to get more girls interested and excited about STEM subjects.")
assert page.has_text?("These subjects are of course crucial. But in the UK, only 1 woman to every 7 men works in science, technology, engineering and maths. We need to get more girls interested and excited about STEM subjects.")
end

test "translated speech" do
Expand Down
4 changes: 2 additions & 2 deletions test/integration/statistical_data_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest

assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("This is not intended to be a comprehensive review of transport performance in London or Great Britain during the Games, but supplements evidence from other sources.")
assert page.has_text?("This is not intended to be a comprehensive review of transport performance in London or Great Britain during the Games, but supplements evidence from other sources.")
end

test "renders metadata and document footer" do
Expand All @@ -29,7 +29,7 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest

within ".gem-c-notice" do
assert page.has_text?("This statistical data set was withdrawn"), "is withdrawn"
assert_has_component_govspeak("Local area walking and cycling in England: 2014 to 2015")
assert page.has_text?("Local area walking and cycling in England: 2014 to 2015")
assert page.has_css?("time[datetime='#{withdrawn_at}']")
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/take_part_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class TakePartTest < ActionDispatch::IntegrationTest
assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])

assert_has_component_govspeak("There are roughly 20,000 local councillors in England. Councillors are elected to the local council to represent their own local community, so they must either live or work in the area.")
assert page.has_text?("There are roughly 20,000 local councillors in England. Councillors are elected to the local council to represent their own local community, so they must either live or work in the area.")
end
end
2 changes: 1 addition & 1 deletion test/integration/topical_event_about_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item('topical_event_about_page')
assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("The risk of Ebola to the UK remains low. The virus is only transmitted by direct contact with the blood or bodily fluids of an infected person.")
assert page.has_text?("The risk of Ebola to the UK remains low. The virus is only transmitted by direct contact with the blood or bodily fluids of an infected person.")
assert_has_contents_list([
{ text: "Response in the UK", id: "response-in-the-uk" },
{ text: "Response in Africa", id: "response-in-africa" },
Expand Down
4 changes: 2 additions & 2 deletions test/integration/travel_advice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TravelAdviceTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item('full-country')

assert page.has_css?("h1", text: "Summary")
assert_has_component_govspeak("The main opposition party has called for mass protests against the government in Tirana on 18 February 2017. The political atmosphere is likely to become changeable as the country approaches national elections on 18 June 2017.")
assert page.has_text?("The main opposition party has called for mass protests against the government in Tirana on 18 February 2017. The political atmosphere is likely to become changeable as the country approaches national elections on 18 June 2017.")

assert_has_component_metadata_pair("Still current at", Date.today.strftime("%-d %B %Y"))
assert_has_component_metadata_pair("Updated", Date.parse(@content_item["details"]["reviewed_at"]).strftime("%-d %B %Y"))
Expand All @@ -55,7 +55,7 @@ class TravelAdviceTest < ActionDispatch::IntegrationTest

assert page.has_css?("title", visible: false, text: "#{first_part['title']} - #{@content_item['title']}")
assert page.has_css?("h1", text: first_part['title'])
assert_has_component_govspeak("Public security is generally good, particularly in Tirana, and Albanians are very hospitable to visitors.")
assert page.has_text?("Public security is generally good, particularly in Tirana, and Albanians are very hospitable to visitors.")

refute page.has_css?(".map")
refute page.has_css?(shared_component_selector("metadata"))
Expand Down
2 changes: 1 addition & 1 deletion test/integration/world_location_news_article_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WorldLocationNewsArticleTest < ActionDispatch::IntegrationTest

assert_has_component_title(@content_item["title"])
assert page.has_text?(@content_item["description"])
assert_has_component_govspeak("As with the core Chevening Scheme this fellowship is an open competition. Applications from eligible countries will be assessed against each other by an independent panel and the top application for each topic received will be awarded.")
assert page.has_text?("As with the core Chevening Scheme this fellowship is an open competition. Applications from eligible countries will be assessed against each other by an independent panel and the top application for each topic received will be awarded.")
end

test "renders first published, from and part of in metadata and document footer" do
Expand Down
4 changes: 0 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ def assert_has_component_title(title)
end
end

def assert_has_component_govspeak(content)
assert page.has_text?(content.squish)
end

def assert_has_component_organisation_logo(logo, index = 1)
within(shared_component_selector("organisation_logo") + ":nth-of-type(#{index})") do
assert_equal logo, JSON.parse(page.text).deep_symbolize_keys
Expand Down

0 comments on commit 3cafef2

Please sign in to comment.