Sha256: 27413dfcd380990f86db503df2591b0d978c57f72b81c8afdf171ff5afa2bd67

Contents?: true

Size: 711 Bytes

Versions: 339

Compression:

Stored size: 711 Bytes

Contents

# -*- coding: utf-8 -*-
require "helper"

module Nokogiri
  module HTML
    if RUBY_VERSION =~ /^1\.9/
      class TestNodeEncoding < Nokogiri::TestCase
        def test_inner_html
          doc = Nokogiri::HTML File.open(SHIFT_JIS_HTML, 'rb')

          hello = "こんにちは"

          contents = doc.at('h2').inner_html
          assert_equal doc.encoding, contents.encoding.name
          assert_match hello.encode('Shift_JIS'), contents

          contents = doc.at('h2').inner_html(:encoding => 'UTF-8')
          assert_match hello, contents

          doc.encoding = 'UTF-8'
          contents = doc.at('h2').inner_html
          assert_match hello, contents
        end
      end
    end
  end
end

Version data entries

339 entries across 339 versions & 33 rubygems

Version Path
nokogiri-1.6.7.1-java test/html/test_node_encoding.rb
nokogiri-1.6.7 test/html/test_node_encoding.rb
nokogiri-1.6.7-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7-java test/html/test_node_encoding.rb
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.3.1-x64-mingw32/test/html/test_node_encoding.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.3.1-x64-mingw32/test/html/test_node_encoding.rb
nokogiri-1.6.7.rc4 test/html/test_node_encoding.rb
nokogiri-1.6.7.rc4-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7.rc4-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7.rc4-java test/html/test_node_encoding.rb
nokogiri-1.6.6.4 test/html/test_node_encoding.rb
nokogiri-1.6.6.4-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.6.4-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.6.4-java test/html/test_node_encoding.rb
nokogiri-1.6.6.3 test/html/test_node_encoding.rb
nokogiri-1.6.6.3-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.6.3-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.6.3-java test/html/test_node_encoding.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.6.2/test/html/test_node_encoding.rb