Skip to content

Commit

Permalink
Stub configuration method in pages helper spec
Browse files Browse the repository at this point in the history
Instead of globally including a module into the tet controller
we stub the one method the spec uses
  • Loading branch information
tvdeyen committed Sep 2, 2021
1 parent 28b06fe commit 2acb952
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions spec/helpers/alchemy/pages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module Alchemy
let(:public_page) { create(:alchemy_page, :public) }
let(:klingon) { create(:alchemy_language, :klingon) }
let(:klingon_language_root) { create(:alchemy_page, :language_root, language: klingon) }
let(:prefix_locale?) { false }

before do
ActionView::TestCase::TestController.include Alchemy::ConfigurationMethods
# helper.controller.class_eval { include Alchemy::ConfigurationMethods }
allow(helper).to receive(:prefix_locale?) { prefix_locale? }
@root_page = language_root # We need this instance variable in the helpers
end

Expand All @@ -34,9 +34,8 @@ module Alchemy
context "when block is given" do
it "passes it on to the render method" do
expect(helper).to receive(:current_alchemy_site).and_return(default_site)
expect(helper)
.to receive(:render)
.with(default_site) { |&block| expect(block).to be }
expect(helper).to receive(:render)
.with(default_site) { |&block| expect(block).to be }

helper.render_site_layout { true }
end
Expand Down Expand Up @@ -210,6 +209,8 @@ module Alchemy
# Always create a language root page for klingon
before { klingon_language_root }

let(:prefix_locale?) { true }

it "should render two language links" do
expect(helper.language_links).to have_selector("a", count: 2)
end
Expand Down

0 comments on commit 2acb952

Please sign in to comment.