From d7860dcee28a38ea386790071407e0ebd3e6b979 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 7 May 2024 17:09:59 +0200 Subject: [PATCH] Add spec for PagesHelper#page_title This pushes the spec coverage for the pages_helper to 100%, freeing us of codecov issues. --- spec/helpers/alchemy/pages_helper_spec.rb | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/spec/helpers/alchemy/pages_helper_spec.rb b/spec/helpers/alchemy/pages_helper_spec.rb index 80f28572e0..82d0613ea1 100644 --- a/spec/helpers/alchemy/pages_helper_spec.rb +++ b/spec/helpers/alchemy/pages_helper_spec.rb @@ -272,6 +272,45 @@ module Alchemy end end + describe "#page_title" do + let(:response) { double("response", status: 200) } + + before do + allow(helper).to receive(:response) { response } + @page = public_page + end + + subject { helper.page_title } + + context "when current page has a title set" do + before { public_page.title = "My Public Page" } + + it { is_expected.to eq "My Public Page" } + end + + context "when current page has no title set" do + before do + language_root.title = "Title from language root" + end + + context "when current page is the language root page" do + before { @page = language_root } + + it { is_expected.to eq "Title from language root" } + end + end + + context "when response status is not 200" do + let(:response) { double("response", status: 404) } + + before { public_page.title = "My Public Page" } + + it "should return the status code" do + is_expected.to eq "404" + end + end + end + describe "meta data" do before { @page = public_page }