Sha256: 02f1c0ba7d2ad9c02dd0a4d63053d3d672edaf5f86b8121916dfed9cf2252df9

Contents?: true

Size: 903 Bytes

Versions: 10

Compression:

Stored size: 903 Bytes

Contents

require 'helper'
require 'peddler/parser'

class TestPeddlerParser < MiniTest::Test
  def assert_parser(klass, *content_types, body: '')
    content_types.each do |content_type|
      res = OpenStruct.new(
        headers: { 'Content-Type' => content_type },
        body: body
      )
      parser = Peddler::Parser.new(res, 'Cp1252')

      assert_kind_of klass, parser
    end
  end

  def test_parses_xml
    assert_parser Peddler::XMLParser,
                  'text/xml',
                  'text/xml; charset=UTF-8'
  end

  def test_parses_incorrect_content_type
    assert_parser Peddler::XMLParser,
                  'xml; charset=UTF-8',
                  body: '<?xml version="1.0"?><GetLowestOfferListingsForASINResponse>...'
  end

  def test_parses_flat_files
    assert_parser Peddler::FlatFileParser,
                  'text/plain',
                  'application/octet-stream'
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
peddler-1.6.3 test/unit/peddler/test_parser.rb
peddler-1.6.2 test/unit/peddler/test_parser.rb
peddler-1.6.1 test/unit/peddler/test_parser.rb
peddler-1.6.0 test/unit/peddler/test_parser.rb
peddler-1.5.0 test/unit/peddler/test_parser.rb
peddler-1.4.1 test/unit/peddler/test_parser.rb
peddler-1.4.0 test/unit/peddler/test_parser.rb
peddler-1.3.0 test/unit/peddler/test_parser.rb
peddler-1.2.0 test/unit/peddler/test_parser.rb
peddler-1.1.1 test/unit/peddler/test_parser.rb