diff --git a/spec/components/follow_button_spec.rb b/spec/components/follow_button_spec.rb index 739db7e91..9ae5fe887 100644 --- a/spec/components/follow_button_spec.rb +++ b/spec/components/follow_button_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Components::FollowButton, type: :component do context "when the follower is not following the target" do let(:button) { allow(follower).to receive(:following?).with(target).and_return false - render_inline(described_class.new(follower: follower, target: target)).to_html + render described_class.new(follower: follower, target: target) } it "creates a button" do @@ -27,14 +27,14 @@ RSpec.describe Components::FollowButton, type: :component do it "links to the create path for the target's follows resource" do # rubocop:todo RSpec/MultipleExpectations expect(button).to include "method=\"post\"" - expect(button).to include "action=\"/creators/#{target.to_param}/follows\"" + expect(button).to include "action=\"http://test.host/creators/#{target.to_param}/follows\"" end end context "when the follower is already following the target" do let(:button) { allow(follower).to receive(:following?).with(target).and_return :accepted - render_inline(described_class.new(follower: follower, target: target)).to_html + render described_class.new(follower: follower, target: target) } it "creates a button" do @@ -47,7 +47,7 @@ RSpec.describe Components::FollowButton, type: :component do it "links to the delete path for the target's follows resource" do # rubocop:todo RSpec/MultipleExpectations expect(button).to include "name=\"_method\" value=\"delete\"" - expect(button).to include "action=\"/creators/#{target.to_param}/follows\"" + expect(button).to include "action=\"http://test.host/creators/#{target.to_param}/follows\"" end end end diff --git a/spec/support/phlex.rb b/spec/support/phlex.rb new file mode 100644 index 000000000..38d2b5b03 --- /dev/null +++ b/spec/support/phlex.rb @@ -0,0 +1,19 @@ +module PhlexTestHelpers + def render(...) + view_context.render(...) + end + + delegate :view_context, to: :controller + + def controller + @controller ||= ActionView::TestCase::TestController.new + end + + def sign_in(user) + allow(controller).to receive(:current_user).and_return(user) + end +end + +RSpec.configure do |config| + config.include PhlexTestHelpers, type: :component +end