Sha256: 0afed69399c39ca4d84e0ec0cd4c7b99a4fa3ad0fe94a6db48c0b8b56dee9cf4

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'helper'
require 'peddler/xml_response_parser'

class TestPeddlerXMLResponseParser < MiniTest::Test
  def test_parses_responses
    body = '<Response><Result><Foo>Bar</Foo></Result></Response>'
    parser = Peddler::XMLResponseParser.new(response(body))
    assert_equal 'Bar', parser.parse['Foo']
  end

  def test_parses_messages
    body = '<Response><MessageType>ProcessingReport</MessageType><Message><Foo>Bar</Foo></Message></Response>'
    parser = Peddler::XMLResponseParser.new(response(body))
    assert_equal 'Bar', parser.parse['Foo']
  end

  def test_parses_reports
    body = '<fooReports><fooReport><foo>Bar</foo></fooReport></fooReports>'
    parser = Peddler::XMLResponseParser.new(response(body))
    assert_equal 'Bar', parser.parse['foo']
  end

  def test_parses_next_token
    body = '<Response><Result><NextToken>123</NextToken></Result></Response>'
    parser = Peddler::XMLResponseParser.new(response(body))
    assert_equal '123', parser.next_token
  end

  private

  def response(body)
    OpenStruct.new(
      body: body,
      headers: { 'Content-Type' => 'text/xml', 'Content-Length' => body.size }
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
peddler-1.6.3 test/unit/peddler/test_xml_response_parser.rb
peddler-1.6.2 test/unit/peddler/test_xml_response_parser.rb
peddler-1.6.1 test/unit/peddler/test_xml_response_parser.rb