Repository: yippee-fun/phlex (ruby)

Issue:
Extract nokogiri and capybara testing extensions



Discussion:

Patch:
diff --git a/Gemfile b/Gemfile
--- a/Gemfile
+++ b/Gemfile
@@ -5,11 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
 
 gemspec
 
-gem "benchmark-ips"
-gem "benchmark-memory"
-gem "capybara"
 gem "rubocop"
-gem "solargraph"
 gem "sus"
 gem "syntax_suggest"
 gem "zeitwerk"


Test patch:
diff --git a/lib/phlex/testing/capybara.rb b/lib/phlex/testing/capybara.rb
deleted file mode 100644
--- a/lib/phlex/testing/capybara.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require "capybara"
-require_relative "view_helper"
-
-module Phlex::Testing
-	module Capybara
-		module ViewHelper
-			include Phlex::Testing::ViewHelper
-
-			def self.included(klass)
-				if defined?(Minitest::Test) && klass < Minitest::Test
-					require "capybara/minitest"
-					include ::Capybara::Minitest::Assertions
-				end
-			end
-
-			attr_accessor :page
-
-			def render(view, &block)
-				@page = ::Capybara::Node::Simple.new(super)
-			end
-		end
-	end
-end
diff --git a/lib/phlex/testing/nokogiri.rb b/lib/phlex/testing/nokogiri.rb
deleted file mode 100644
--- a/lib/phlex/testing/nokogiri.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require "nokogiri"
-require_relative "view_helper"
-
-module Phlex::Testing
-	module Nokogiri
-		module DocumentHelper
-			include Phlex::Testing::ViewHelper
-
-			def render(view, &block)
-				::Nokogiri::HTML5(super)
-			end
-		end
-
-		module FragmentHelper
-			include Phlex::Testing::ViewHelper
-
-			def render(view, &block)
-				::Nokogiri::HTML5.fragment(super)
-			end
-		end
-	end
-end
diff --git a/lib/phlex/testing/rails.rb b/lib/phlex/testing/rails.rb
deleted file mode 100644
--- a/lib/phlex/testing/rails.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "view_helper"
-
-module Phlex::Testing
-	module Rails
-		module ViewHelper
-			include Phlex::Testing::ViewHelper
-
-			def view_context
-				controller.view_context
-			end
-
-			def controller
-				@controller ||= ActionView::TestCase::TestController.new
-			end
-		end
-	end
-end
diff --git a/test/phlex/testing/capybara/view_helper.rb b/test/phlex/testing/capybara/view_helper.rb
deleted file mode 100644
--- a/test/phlex/testing/capybara/view_helper.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require "phlex/testing/capybara"
-
-class Example < Phlex::HTML
-	def template
-		h1 { "👋" }
-	end
-end
-
-describe Phlex::Testing::Capybara::ViewHelper do
-	include Phlex::Testing::Capybara::ViewHelper
-
-	describe "#render" do
-		it "sets the page" do
-			render Example.new
-
-			expect(page.all("h1").first.text).to be == "👋"
-		end
-	end
-end
diff --git a/test/phlex/testing/nokogiri/document_helper.rb b/test/phlex/testing/nokogiri/document_helper.rb
deleted file mode 100644
--- a/test/phlex/testing/nokogiri/document_helper.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require "phlex/testing/nokogiri"
-
-class Example < Phlex::HTML
-	def template
-		h1 { "👋" }
-	end
-end
-
-describe Phlex::Testing::Nokogiri::DocumentHelper do
-	include Phlex::Testing::Nokogiri::DocumentHelper
-
-	describe "#render" do
-		it "returns a Nokogiri fragment" do
-			output = render Example.new
-
-			expect(output).to be_a Nokogiri::HTML5::Document
-			expect(output.css("h1").text).to be == "👋"
-		end
-	end
-end
diff --git a/test/phlex/testing/nokogiri/fragment_helper.rb b/test/phlex/testing/nokogiri/fragment_helper.rb
deleted file mode 100644
--- a/test/phlex/testing/nokogiri/fragment_helper.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require "phlex/testing/nokogiri"
-
-class Example < Phlex::HTML
-	def template
-		h1 { "👋" }
-	end
-end
-
-describe Phlex::Testing::Nokogiri::FragmentHelper do
-	include Phlex::Testing::Nokogiri::FragmentHelper
-
-	describe "#render" do
-		it "returns a Nokogiri fragment" do
-			output = render Example.new
-
-			expect(output).to be_a Nokogiri::HTML5::DocumentFragment
-			expect(output.css("h1").text).to be == "👋"
-		end
-	end
-end