Testing HTML Views with Nokogiri [beta]
The phlex-testing-nokogiri
gem provides helpers for working with rendered views as Nokogiri documents and fragments.
Installation
Add the following to the test group in your Gemfile and run bundle install
.
gem "phlex-testing-nokogiri"
Testing Documents
If your view represents a whole HTML document, you can require phlex/testing/nokogiri
and include the Phlex::Testing::Nokogiri::DocumentHelper
module to render your view as Nokogiri::Document
using the render
method.
Testing Fragments
If your view represents a fragment (partial), you can require phlex/testing/nokogiri
and include the Phlex::Testing::Nokogiri::FragmentHelper
module to render your view as Nokogiri::Fragment
with the render
method.