Sha256: 54ce45f31529079d27431cbadfea5678ed9a297d866b25c1452b8c529b6f611f

Contents?: true

Size: 869 Bytes

Versions: 7

Compression:

Stored size: 869 Bytes

Contents

require 'helper'
require 'peddler/xml_response_parser'

class TestPeddlerXMLResponseParser < MiniTest::Test
  def setup
    body = '<Response><Result><NextToken>123</NextToken>'\
           '<Foo>Bar</Foo></Result></Response>'

    @parser = Peddler::XMLResponseParser.new(response(body))
  end

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

  def test_parses_data
    assert_equal 'Bar', @parser.parse['Foo']
  end

  def test_parses_message_data
    body_with_message = '<Response><Message><NextToken>123</NextToken>'\
           '<Foo>Bar</Foo></Message></Response>'
    parser = Peddler::XMLResponseParser.new(response(body_with_message))
    assert_equal 'Bar', parser.parse['Foo']
  end

  def test_next_token
    assert_equal '123', @parser.next_token
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
peddler-1.4.1 test/unit/peddler/test_xml_response_parser.rb
peddler-1.4.0 test/unit/peddler/test_xml_response_parser.rb
peddler-1.3.0 test/unit/peddler/test_xml_response_parser.rb
peddler-1.2.0 test/unit/peddler/test_xml_response_parser.rb
peddler-1.1.1 test/unit/peddler/test_xml_response_parser.rb
peddler-1.1.0 test/unit/peddler/test_xml_response_parser.rb
peddler-1.0.2 test/unit/peddler/test_xml_response_parser.rb