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 = /