Government Digital Service
125 Kingsway
Holborn
London
WC2B 6NH
Email people@digital.cabinet-office.gov.uk
helpdesk +4412345 67890
# encoding: UTF-8 require 'test_helper' class GovspeakContactsTest < Minitest::Test def build_contact(attrs={}) { id: attrs.fetch(:id, 123456), content_id: attrs.fetch(:content_id, "4f3383e4-48a2-4461-a41d-f85ea8b89ba0"), title: attrs.fetch(:title, "Government Digital Service"), recipient: attrs.fetch(:recipient, ""), street_address: attrs.fetch(:street_address, "125 Kingsway"), postal_code: attrs.fetch(:postal_code, "WC2B 6NH"), locality: attrs.fetch(:locality, "Holborn"), region: attrs.fetch(:region, "London"), country_code: attrs.fetch(:country_code, "gb"), email: attrs.fetch(:email, "people@digital.cabinet-office.gov.uk"), contact_form_url: attrs.fetch(:contact_form_url, ""), contact_numbers: attrs.fetch(:contact_numbers, [{ label: "helpdesk", number: "+4412345 67890" }]), comments: attrs.fetch(:comments, ""), worldwide_organisation_path: attrs.fetch(:worldwide_organisation_path, nil), } end def compress_html(html) html.gsub(/[\n\r]+[\s]*/,'') end test "contact is rendered when present in options[:contacts]" do contact = build_contact govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, { contacts: [contact] }).to_html expected_html_output = %{
125 Kingsway
Holborn
London
WC2B 6NH
Email people@digital.cabinet-office.gov.uk
helpdesk +4412345 67890
Email people@digital.cabinet-office.gov.uk
helpdesk +4412345 67890