Sha256: 521ea3fffd2f928c2e875a72173a24acf65fdf005a2dd8104c1639df3ff3ef60

Contents?: true

Size: 934 Bytes

Versions: 7

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

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

7 entries across 7 versions & 1 rubygems

Version Path
peddler-2.0.4 test/unit/peddler/test_parser.rb
peddler-2.0.3 test/unit/peddler/test_parser.rb
peddler-2.0.0 test/unit/peddler/test_parser.rb
peddler-1.6.7 test/unit/peddler/test_parser.rb
peddler-1.6.6 test/unit/peddler/test_parser.rb
peddler-1.6.5 test/unit/peddler/test_parser.rb
peddler-1.6.4 test/unit/peddler/test_parser.rb