Sha256: 68f2c56907d50901d1b6b55af5afcf46024b7d52f7e2ac53a676011ff4cb8462

Contents?: true

Size: 1.39 KB

Versions: 23

Compression:

Stored size: 1.39 KB

Contents

require 'mechanize/test_case'

class TestMechanizePluggableParser < Mechanize::TestCase

  def setup
    super

    @pp = @mech.pluggable_parser
  end

  def test_aref
    @pp['text/html'] = Mechanize::Download

    assert_equal Mechanize::Download, @pp['text/html']
  end

  def test_csv
    @pp.csv = Mechanize::Download

    assert_equal Mechanize::Download, @pp['text/csv']
  end

  def test_html
    assert_equal Mechanize::Page, @pp['text/html']

    @pp.html = Mechanize::Download

    assert_equal Mechanize::Download, @pp['text/html']
  end

  def test_parser
    assert_equal Mechanize::XmlFile, @pp.parser('text/xml')
    assert_equal Mechanize::File, @pp.parser(nil)
  end

  def test_parser_mime
    @pp['image/png'] = :png

    assert_equal :png, @pp.parser('x-image/x-png')
    assert_equal :png, @pp.parser('image/png')
    assert_equal Mechanize::Image, @pp.parser('image')
  end

  def test_parser_bogus
    assert_nil @pp['bogus']

    assert_equal Mechanize::File, @pp.parser('bogus')
  end

  def test_pdf
    @pp.pdf = Mechanize::Download

    assert_equal Mechanize::Download, @pp['application/pdf']
  end

  def test_xml
    assert_equal Mechanize::XmlFile, @pp['text/xml']
    assert_equal Mechanize::XmlFile, @pp['application/xml']

    @pp.xml = Mechanize::Download

    assert_equal Mechanize::Download, @pp['text/xml']
    assert_equal Mechanize::Download, @pp['application/xml']
  end

end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
mechanize-2.10.0 test/test_mechanize_pluggable_parser.rb
mechanize-2.9.2 test/test_mechanize_pluggable_parser.rb
mechanize-2.9.1 test/test_mechanize_pluggable_parser.rb
mechanize-2.9.0 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.5 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.4 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.3 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.2 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.1 test/test_mechanize_pluggable_parser.rb
mechanize-2.8.0 test/test_mechanize_pluggable_parser.rb
mechanize-2.7.7 test/test_mechanize_pluggable_parser.rb
husc-0.2.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_pluggable_parser.rb
husc-0.2.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_pluggable_parser.rb
husc-0.1.1 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_pluggable_parser.rb
husc-0.1.0 vendor/bundle/gems/mechanize-2.7.6/test/test_mechanize_pluggable_parser.rb
mechanize-2.7.6 test/test_mechanize_pluggable_parser.rb
mechanize-2.7.5 test/test_mechanize_pluggable_parser.rb
mechanize-2.7.4 test/test_mechanize_pluggable_parser.rb
mechanize-2.7.3 test/test_mechanize_pluggable_parser.rb
mechanize-2.7.2 test/test_mechanize_pluggable_parser.rb