Sha256: 345b1aba49505f9d5525233cf7ac106bc39620255ff7a230cd7057004f705189

Contents?: true

Size: 1.71 KB

Versions: 321

Compression:

Stored size: 1.71 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestParseOptions < Nokogiri::TestCase
      def test_new
        options = Nokogiri::XML::ParseOptions.new
        assert_equal 0, options.options
      end

      def test_to_i
        options = Nokogiri::XML::ParseOptions.new
        assert_equal 0, options.to_i
      end

      ParseOptions.constants.each do |constant|
        next if constant == 'STRICT'
        class_eval %{
          def test_predicate_#{constant.downcase}
            options = ParseOptions.new(ParseOptions::#{constant})
            assert options.#{constant.downcase}?

            assert ParseOptions.new.#{constant.downcase}.#{constant.downcase}?
          end
        }
      end

      def test_strict_noent
        options = ParseOptions.new.recover.noent
        assert !options.strict?
      end

      def test_new_with_argument
        options = Nokogiri::XML::ParseOptions.new 1 << 1
        assert_equal 1 << 1, options.options
      end

      def test_unsetting
        options = Nokogiri::XML::ParseOptions.new Nokogiri::XML::ParseOptions::DEFAULT_HTML
        assert options.nonet?
        assert options.recover?
        options.nononet.norecover
        assert ! options.nonet?
        assert ! options.recover?
        options.nonet.recover
        assert options.nonet?
        assert options.recover?
      end

      def test_chaining
        options = Nokogiri::XML::ParseOptions.new.recover.noent
        assert options.recover?
        assert options.noent?
      end

      def test_inspect
        options = Nokogiri::XML::ParseOptions.new.recover.noent
        ins = options.inspect
        assert_match(/recover/, ins)
        assert_match(/noent/, ins)
      end
    end
  end
end

Version data entries

321 entries across 311 versions & 27 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.4/test/xml/test_parse_options.rb
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.5/test/xml/test_parse_options.rb
nokogiri-1.9.0.rc1 test/xml/test_parse_options.rb
nokogiri-1.9.0.rc1-x86-mingw32 test/xml/test_parse_options.rb
nokogiri-1.9.0.rc1-x64-mingw32 test/xml/test_parse_options.rb
nokogiri-1.9.0.rc1-java test/xml/test_parse_options.rb
nokogiri-1.8.5 test/xml/test_parse_options.rb
nokogiri-1.8.5-x86-mingw32 test/xml/test_parse_options.rb
nokogiri-1.8.5-x64-mingw32 test/xml/test_parse_options.rb
nokogiri-1.8.5-java test/xml/test_parse_options.rb
daslabs-0.12.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_parse_options.rb
daslabs-0.11.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_parse_options.rb
nokogiri-1.8.4 test/xml/test_parse_options.rb
nokogiri-1.8.4-x86-mingw32 test/xml/test_parse_options.rb
nokogiri-1.8.4-x64-mingw32 test/xml/test_parse_options.rb
nokogiri-1.8.4-java test/xml/test_parse_options.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.3/test/xml/test_parse_options.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.3/test/xml/test_parse_options.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.3/test/xml/test_parse_options.rb
tdiary-5.0.9 vendor/bundle/gems/nokogiri-1.8.2/test/xml/test_parse_options.rb