Sha256: 1be78102b84b1583ee56485b140d49ae2b25e4feddf348bcdff4a3d4878981f6

Contents?: true

Size: 1.76 KB

Versions: 66

Compression:

Stored size: 1.76 KB

Contents

require 'test_helper'

class USPSReturnsTest < ActiveSupport::TestCase
  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

66 entries across 66 versions & 2 rubygems

Version Path
workarea-core-3.4.13 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.12 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
active_shipping-2.1.1 test/unit/carriers/usps_returns_test.rb
active_shipping-2.1.0 test/unit/carriers/usps_returns_test.rb
active_shipping-2.0.1 test/unit/carriers/usps_returns_test.rb
active_shipping-2.0.0 test/unit/carriers/usps_returns_test.rb