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
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/test/html/test_node_encoding.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/test/html/test_node_encoding.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/test/html/test_node_encoding.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/test/html/test_node_encoding.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/test/html/test_node_encoding.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/test/html/test_node_encoding.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/test/html/test_node_encoding.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/test/html/test_node_encoding.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/test/html/test_node_encoding.rb
nokogiri-1.6.7.2 test/html/test_node_encoding.rb
nokogiri-1.6.7.2-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7.2-x64-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7.2-java test/html/test_node_encoding.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/test/html/test_node_encoding.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.1/test/html/test_node_encoding.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/test/html/test_node_encoding.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/test/html/test_node_encoding.rb
nokogiri-1.6.7.1 test/html/test_node_encoding.rb
nokogiri-1.6.7.1-x86-mingw32 test/html/test_node_encoding.rb
nokogiri-1.6.7.1-x64-mingw32 test/html/test_node_encoding.rb