From e74e233548f6cb4804ed9551e4272276d1f9264d Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 16 Oct 2023 15:20:24 +0200 Subject: [PATCH] Add spec for `answer_share_url` --- spec/helpers/social_helper_spec.rb | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/helpers/social_helper_spec.rb diff --git a/spec/helpers/social_helper_spec.rb b/spec/helpers/social_helper_spec.rb new file mode 100644 index 00000000..6841cdef --- /dev/null +++ b/spec/helpers/social_helper_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe SocialHelper, type: :helper do + let(:user) { FactoryBot.create(:user) } + let(:answer) do + FactoryBot.create( + :answer, + user:, + content: "this is an answer\nwith multiple lines\nand **FORMATTING**", + question_content: "this is a question .... or is it?" + ) + end + + before do + stub_const("APP_CONFIG", { + "hostname" => "example.com", + "https" => true, + "items_per_page" => 5, + }) + end + + describe "#answer_share_url" do + subject { answer_share_url(answer) } + + it "returns a proper share link" do + expect(subject).to eq(<<~URL.strip) + https://example.com/@#{answer.user.screen_name}/a/#{answer.id} + URL + end + end +end