mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
get phlex component tests working
This commit is contained in:
2 files changed
+23
-4
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user