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.5.27 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.26 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.45 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.25 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.23 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.44 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.22 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.43 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.21 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.42 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.20 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.41 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.19 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.40 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.18 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.39 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.17 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.38 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.5.16 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb
workarea-core-3.4.37 vendor/active_shipping/test/unit/carriers/usps_returns_test.rb