Sha256: 131adbeb4a480d9744c541425b40479e221cb1e07abbb92e8661c28a40186ac6

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 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)

      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

3 entries across 3 versions & 1 rubygems

Version Path
peddler-1.1.0 test/unit/peddler/test_parser.rb
peddler-1.0.2 test/unit/peddler/test_parser.rb
peddler-1.0.1 test/unit/peddler/test_parser.rb