Skip to content

Commit

Permalink
Merge pull request #614 from sparklemotion/613-update-tests-for-libxm…
Browse files Browse the repository at this point in the history
…l2-encoding-changes

test: work around libxml2 encoding changes
  • Loading branch information
flavorjones committed Jun 7, 2023
2 parents 59cc064 + 762df0c commit 74574f9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/test_mechanize_page_link.rb
@@ -1,5 +1,7 @@
# coding: utf-8

puts "Nokogiri::VERSION_INFO: #{Nokogiri::VERSION_INFO}"

require 'mechanize/test_case'

class TestMechanizePageLink < Mechanize::TestCase
Expand Down Expand Up @@ -111,11 +113,15 @@ def test_encoding_charset_after_title
def test_encoding_charset_after_title_bad
skip_if_nkf_dependency

# https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
skip if Nokogiri.uses_libxml?([">= 2.11.0", "<= 2.11.4"])
expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'

page = util_page UTF8

assert_equal false, page.encoding_error?

assert_equal 'UTF-8', page.encoding
assert_equal expected_encoding, page.encoding
end

def test_encoding_charset_after_title_double_bad
Expand All @@ -131,6 +137,10 @@ def test_encoding_charset_after_title_double_bad
def test_encoding_charset_bad
skip_if_nkf_dependency

# https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
skip if Nokogiri.uses_libxml?([">= 2.11.0", "<= 2.11.4"])
expected_encoding = Nokogiri.uses_libxml?("< 2.11.0") ? 'UTF-8' : 'Shift_JIS'

page = util_page "<title>#{UTF8_TITLE}</title>"
page.encodings.replace %w[
UTF-8
Expand All @@ -139,7 +149,7 @@ def test_encoding_charset_bad

assert_equal false, page.encoding_error?

assert_equal 'UTF-8', page.encoding
assert_equal expected_encoding, page.encoding
end

def test_encoding_meta_charset
Expand Down

0 comments on commit 74574f9

Please sign in to comment.