diff --git a/spec/views/layouts/application_layout_spec.rb b/spec/views/layouts/application_layout_spec.rb new file mode 100644 index 000000000..2ee571e09 --- /dev/null +++ b/spec/views/layouts/application_layout_spec.rb @@ -0,0 +1,57 @@ +require "rails_helper" + +RSpec.describe "layouts/application" do + shared_examples "analytics cookie elements" do |banner:, scripts:| + define_negated_matcher :not_match, :match + + it "#{banner ? 'includes' : 'omits'} the cookie banner" do + banner_text = "We’d like to use analytics cookies so we can understand how you use the service and make improvements." + if banner + expect(rendered).to match(banner_text) + else + expect(rendered).not_to match(banner_text) + end + end + + it "#{scripts ? 'includes' : 'omits'} the analytics scripts" do + gtm_script_tag = /