Sha256: b4ec5fdf1feebb439bfae2f3dbde7c4263f2c9286143e1d3fb06a42f000f89d2

Contents?: true

Size: 1.75 KB

Versions: 38

Compression:

Stored size: 1.75 KB

Contents

require 'test_helper'

class USPSReturnsTest < Minitest::Test
  include ActiveShipping::Test::Fixtures

  attr_reader :carrier

  def setup
    @carrier = USPSReturns.new
  end

  def test_external_return_label_response_failure_should_raise_exception
    @carrier.expects(:commit).returns(xml_fixture('usps_returns/external_return_label_response_failure'))
    assert_raises ResponseError do
      @carrier.external_return_label_request(Nokogiri::XML({}))
    end
  end

  def test_external_return_label_errors
    response = Nokogiri::XML(xml_fixture('usps_returns/external_return_label_response_failure'))
    errors = @carrier.send(:external_return_label_errors, response)
    assert_equal errors.length > 0, true
  end

  def test_parse_external_return_label_response_raises_error
    response = xml_fixture('usps_returns/external_return_label_response_failure')
    assert_raises ResponseError do
      @carrier.send(:parse_external_return_label_response, response)
    end
  end

  def test_parse_external_return_label_response_returns_object
    response = xml_fixture('usps_returns/external_return_label_response')

    assert_equal @carrier.send(:parse_external_return_label_response, response).is_a?(ExternalReturnLabelResponse), true
    assert_equal @carrier.send(:parse_external_return_label_response, response).tracking_number, "9202090140694100000410"
    assert_equal @carrier.send(:parse_external_return_label_response, response).postal_routing, "420770739921"
  end

  def test_external_return_label_response_should_return_external_label_response
    @carrier.expects(:commit).returns(xml_fixture('usps_returns/external_return_label_response'))
    assert_equal @carrier.external_return_label_request(Nokogiri::XML({})).tracking_number, "9202090140694100000410"
  end

end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
active_shipping-1.14.2 test/unit/carriers/usps_returns_test.rb
active_shipping-1.14.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.14.0 test/unit/carriers/usps_returns_test.rb
active_shipping-1.13.4 test/unit/carriers/usps_returns_test.rb
active_shipping-1.13.3 test/unit/carriers/usps_returns_test.rb
active_shipping-1.13.2 test/unit/carriers/usps_returns_test.rb
active_shipping-1.13.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.13.0 test/unit/carriers/usps_returns_test.rb
active_shipping-1.12.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.12.0 test/unit/carriers/usps_returns_test.rb
active_shipping-1.11.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.11.0 test/unit/carriers/usps_returns_test.rb
active_shipping-1.10.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.9.2 test/unit/carriers/usps_returns_test.rb
active_shipping-1.9.1 test/unit/carriers/usps_returns_test.rb
active_shipping-1.9.0 test/unit/carriers/usps_returns_test.rb
active_shipping-1.8.6 test/unit/carriers/usps_returns_test.rb
active_shipping-1.8.5 test/unit/carriers/usps_returns_test.rb
active_shipping-1.8.4 test/unit/carriers/usps_returns_test.rb
active_shipping-1.8.3 test/unit/carriers/usps_returns_test.rb