From 3cafef219196157fdbb136be09ca60adc8d23956 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Mon, 4 Jun 2018 14:07:15 +0000 Subject: [PATCH] Remove assert_has_component_govspeak method - since it's now just has_text, no need for it to be a separate method - update tests --- test/integration/answer_test.rb | 2 +- test/integration/case_study_test.rb | 2 +- test/integration/consultation_test.rb | 2 +- test/integration/contact_test.rb | 4 ++-- test/integration/detailed_guide_test.rb | 2 +- test/integration/document_collection_test.rb | 4 ++-- test/integration/fatality_notice_test.rb | 4 ++-- test/integration/help_page_test.rb | 2 +- test/integration/html_publication_test.rb | 6 +----- test/integration/publication_test.rb | 6 +++--- test/integration/specialist_document_test.rb | 4 ++-- test/integration/speech_test.rb | 2 +- test/integration/statistical_data_set_test.rb | 4 ++-- test/integration/take_part_test.rb | 2 +- test/integration/topical_event_about_page_test.rb | 2 +- test/integration/travel_advice_test.rb | 4 ++-- test/integration/world_location_news_article_test.rb | 2 +- test/test_helper.rb | 4 ---- 18 files changed, 25 insertions(+), 33 deletions(-) diff --git a/test/integration/answer_test.rb b/test/integration/answer_test.rb index 8b52ba926..ad7cab73b 100644 --- a/test/integration/answer_test.rb +++ b/test/integration/answer_test.rb @@ -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 diff --git a/test/integration/case_study_test.rb b/test/integration/case_study_test.rb index b1284aa40..f929aa5d5 100644 --- a/test/integration/case_study_test.rb +++ b/test/integration/case_study_test.rb @@ -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 diff --git a/test/integration/consultation_test.rb b/test/integration/consultation_test.rb index f92965ff7..548faf25a 100644 --- a/test/integration/consultation_test.rb +++ b/test/integration/consultation_test.rb @@ -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 diff --git a/test/integration/contact_test.rb b/test/integration/contact_test.rb index f35c0d3ce..2dde74439 100644 --- a/test/integration/contact_test.rb +++ b/test/integration/contact_test.rb @@ -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 diff --git a/test/integration/detailed_guide_test.rb b/test/integration/detailed_guide_test.rb index 980e245a0..5ea998988 100644 --- a/test/integration/detailed_guide_test.rb +++ b/test/integration/detailed_guide_test.rb @@ -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 diff --git a/test/integration/document_collection_test.rb b/test/integration/document_collection_test.rb index f612cf6dc..43e9bb991 100644 --- a/test/integration/document_collection_test.rb +++ b/test/integration/document_collection_test.rb @@ -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 @@ -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 diff --git a/test/integration/fatality_notice_test.rb b/test/integration/fatality_notice_test.rb index 6762c4827..d7e4ff1db 100644 --- a/test/integration/fatality_notice_test.rb +++ b/test/integration/fatality_notice_test.rb @@ -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") @@ -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 diff --git a/test/integration/help_page_test.rb b/test/integration/help_page_test.rb index 15806574e..a294f09bf 100644 --- a/test/integration/help_page_test.rb +++ b/test/integration/help_page_test.rb @@ -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 diff --git a/test/integration/html_publication_test.rb b/test/integration/html_publication_test.rb index 6cafc40aa..bb4c9fe18 100644 --- a/test/integration/html_publication_test.rb +++ b/test/integration/html_publication_test.rb @@ -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 @@ -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") diff --git a/test/integration/publication_test.rb b/test/integration/publication_test.rb index 09a122c85..36ead4dbe 100644 --- a/test/integration/publication_test.rb +++ b/test/integration/publication_test.rb @@ -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 @@ -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 @@ -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 diff --git a/test/integration/specialist_document_test.rb b/test/integration/specialist_document_test.rb index 6f450c782..268cc3676 100644 --- a/test/integration/specialist_document_test.rb +++ b/test/integration/specialist_document_test.rb @@ -32,7 +32,7 @@ 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 @@ -40,7 +40,7 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest 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 diff --git a/test/integration/speech_test.rb b/test/integration/speech_test.rb index f54ef096a..fa3fdc719 100644 --- a/test/integration/speech_test.rb +++ b/test/integration/speech_test.rb @@ -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 diff --git a/test/integration/statistical_data_set_test.rb b/test/integration/statistical_data_set_test.rb index a6f5f1660..5b79a598a 100644 --- a/test/integration/statistical_data_set_test.rb +++ b/test/integration/statistical_data_set_test.rb @@ -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 @@ -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 diff --git a/test/integration/take_part_test.rb b/test/integration/take_part_test.rb index 09a04958d..fb824fcb1 100644 --- a/test/integration/take_part_test.rb +++ b/test/integration/take_part_test.rb @@ -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 diff --git a/test/integration/topical_event_about_page_test.rb b/test/integration/topical_event_about_page_test.rb index 31da2ee9f..269ef0fd5 100644 --- a/test/integration/topical_event_about_page_test.rb +++ b/test/integration/topical_event_about_page_test.rb @@ -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" }, diff --git a/test/integration/travel_advice_test.rb b/test/integration/travel_advice_test.rb index f9bd2c7e8..8bf4eb45a 100644 --- a/test/integration/travel_advice_test.rb +++ b/test/integration/travel_advice_test.rb @@ -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")) @@ -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")) diff --git a/test/integration/world_location_news_article_test.rb b/test/integration/world_location_news_article_test.rb index 2f297370d..03d2177a5 100644 --- a/test/integration/world_location_news_article_test.rb +++ b/test/integration/world_location_news_article_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 20991b5b1..d45a6ec42 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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