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.5.0.beta.1-java test/html/test_node_encoding.rb
nokogiri-1.4.2-java test/html/test_node_encoding.rb
nokogiri-1.4.2 test/html/test_node_encoding.rb
rubyjedi-nokogiri_java-1.4.0.20100513161003-java test/html/test_node_encoding.rb
jwagener-nokogiri-1.4.1 test/html/test_node_encoding.rb
revo-nokogiri-1.4.1-java test/html/test_node_encoding.rb
revo-nokogiri-1.4.0.3-java test/html/test_node_encoding.rb
revo-nokogiri-1.4.0-java test/html/test_node_encoding.rb
revo-nokogiri-1.4.0.20100202165440-java test/html/test_node_encoding.rb
nokogiri-1.4.1-x86-mswin32 test/html/test_node_encoding.rb
nokogiri-1.4.1-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.4.1-java test/html/test_node_encoding.rb
nokogiri-1.4.1 test/html/test_node_encoding.rb
superfeedr-nokogiri-1.4.0.20091116183308 test/html/test_node_encoding.rb
caring-nokogiri-1.4.1.pre1 test/html/test_node_encoding.rb
nokogiri-1.4.0-java test/html/test_node_encoding.rb
nokogiri-1.4.0-x86-mswin32 test/html/test_node_encoding.rb
nokogiri-1.4.0-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.4.0 test/html/test_node_encoding.rb