From b544145b9377dc3270ae49b142dfa7fa296fea7a Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 27 Dec 2021 14:15:36 +0100 Subject: [PATCH] Fix `SocialHelper::TwitterMethods` tests so they work anywhere --- spec/helpers/social_helper/twitter_methods_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/helpers/social_helper/twitter_methods_spec.rb b/spec/helpers/social_helper/twitter_methods_spec.rb index 4c334fc6..7a2e8afe 100644 --- a/spec/helpers/social_helper/twitter_methods_spec.rb +++ b/spec/helpers/social_helper/twitter_methods_spec.rb @@ -8,12 +8,20 @@ describe SocialHelper::TwitterMethods, :type => :helper do content: 'a' * 255, question_content: 'q' * 255) } + before do + stub_const("APP_CONFIG", { + 'hostname' => 'example.com', + 'https' => true, + 'items_per_page' => 5 + }) + end + describe '#prepare_tweet' do context 'when the question and answer need to be shortened' do subject { prepare_tweet(answer) } it 'should return a properly formatted tweet' do - expect(subject).to eq("#{'q' * 123}… — #{'a' * 124}… https://justask.rrerr.net/#{user.screen_name}/a/#{answer.id}") + expect(subject).to eq("#{'q' * 123}… — #{'a' * 124}… https://example.com/#{user.screen_name}/a/#{answer.id}") end end @@ -28,7 +36,7 @@ describe SocialHelper::TwitterMethods, :type => :helper do subject { prepare_tweet(answer) } it 'should return a properly formatted tweet' do - expect(subject).to eq("#{answer.question.content} — #{answer.content} https://justask.rrerr.net/#{user.screen_name}/a/#{answer.id}") + expect(subject).to eq("#{answer.question.content} — #{answer.content} https://example.com/#{user.screen_name}/a/#{answer.id}") end end end