Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: formatting and wrap in describe to avoid multiple runs
- Loading branch information
1 parent
c847e1b
commit 4ca5a89
Showing
1 changed file
with
51 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
# frozen_string_literal: true | ||
require "helper" | ||
|
||
class TestNokogiri < Nokogiri::TestCase | ||
def test_libxml_iconv | ||
skip_unless_libxml2("this constant is only set in the C extension when libxml2 is used") | ||
assert Nokogiri.const_defined?(:LIBXML_ICONV_ENABLED) | ||
end | ||
|
||
def test_parse_with_io | ||
doc = Nokogiri.parse( | ||
StringIO.new("<html><head><title></title><body></body></html>") | ||
) | ||
assert_instance_of Nokogiri::HTML::Document, doc | ||
end | ||
|
||
def test_xml? | ||
doc = Nokogiri.parse(File.read(XML_FILE)) | ||
assert doc.xml? | ||
assert !doc.html? | ||
end | ||
|
||
def test_atom_is_xml? | ||
doc = Nokogiri.parse(File.read(XML_ATOM_FILE)) | ||
assert doc.xml? | ||
assert !doc.html? | ||
end | ||
|
||
def test_html? | ||
doc = Nokogiri.parse(File.read(HTML_FILE)) | ||
assert !doc.xml? | ||
assert doc.html? | ||
end | ||
|
||
def test_nokogiri_method_with_html | ||
doc1 = Nokogiri(File.read(HTML_FILE)) | ||
doc2 = Nokogiri.parse(File.read(HTML_FILE)) | ||
assert_equal doc1.serialize, doc2.serialize | ||
end | ||
|
||
def test_nokogiri_method_with_block | ||
doc = Nokogiri { b "bold tag" } | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
end | ||
|
||
def test_make_with_html | ||
doc = Nokogiri.make("<b>bold tag</b>") | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
end | ||
|
||
def test_make_with_block | ||
doc = Nokogiri.make { b "bold tag" } | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
class Nokogiri::TestCase | ||
describe Nokogiri do | ||
def test_libxml_iconv | ||
skip_unless_libxml2("this constant is only set in the C extension when libxml2 is used") | ||
assert(Nokogiri.const_defined?(:LIBXML_ICONV_ENABLED)) | ||
end | ||
|
||
def test_parse_with_io | ||
doc = Nokogiri.parse(StringIO.new("<html><head><title></title><body></body></html>")) | ||
assert_instance_of(Nokogiri::HTML::Document, doc) | ||
end | ||
|
||
def test_xml? | ||
doc = Nokogiri.parse(File.read(XML_FILE)) | ||
assert(doc.xml?) | ||
assert(!doc.html?) | ||
end | ||
|
||
def test_atom_is_xml? | ||
doc = Nokogiri.parse(File.read(XML_ATOM_FILE)) | ||
assert(doc.xml?) | ||
assert(!doc.html?) | ||
end | ||
|
||
def test_html? | ||
doc = Nokogiri.parse(File.read(HTML_FILE)) | ||
assert(!doc.xml?) | ||
assert(doc.html?) | ||
end | ||
|
||
def test_nokogiri_method_with_html | ||
doc1 = Nokogiri(File.read(HTML_FILE)) | ||
doc2 = Nokogiri.parse(File.read(HTML_FILE)) | ||
assert_equal(doc1.serialize, doc2.serialize) | ||
end | ||
|
||
def test_nokogiri_method_with_block | ||
doc = Nokogiri { b("bold tag") } | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
end | ||
|
||
def test_make_with_html | ||
doc = Nokogiri.make("<b>bold tag</b>") | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
end | ||
|
||
def test_make_with_block | ||
doc = Nokogiri.make { b("bold tag") } | ||
assert_equal("<b>bold tag</b>", doc.to_html.chomp) | ||
end | ||
end | ||
end |