Fix `SocialHelper::TwitterMethods` tests so they work anywhere

This commit is contained in:
Andreas Nedbal 2021-12-27 14:15:36 +01:00 committed by Andreas Nedbal
parent 8dd14e4a05
commit b544145b93
1 changed files with 10 additions and 2 deletions

View File

@ -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