Sha256: 5ed22b8328f1d7588a2d7705204992654bd12f4426d61a6357f8fc079bcdbca8

Contents?: true

Size: 1.77 KB

Versions: 23

Compression:

Stored size: 1.77 KB

Contents

require 'test_helper'

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

  def setup
    @carrier   = Kunaki.new
    @items = [{ :sku => 'AF0001', :quantity => 1 }, { :sku => 'AF0002', :quantity => 2 }]
  end

  def test_unsuccessful_rate_request
    @carrier.expects(:ssl_post).returns(xml_fixture('kunaki/unsuccessful_rates_response'))

    assert_raises(ResponseError) do
      begin
        @carrier.find_rates(
          location_fixtures[:ottawa],
          location_fixtures[:beverly_hills],
          package_fixtures.values_at(:book, :wii),
          :items => @items
        )
      rescue ResponseError => e
        assert_equal "Request contains invalid XML syntax", e.response.message
        assert_equal "100", e.response.params["ErrorCode"]
        raise
      end
    end
  end

  def test_successfully_get_rates
    @carrier.expects(:ssl_post).returns(xml_fixture('kunaki/successful_rates_response'))

    response = @carrier.find_rates(
                 location_fixtures[:ottawa],
                 location_fixtures[:london],
                 package_fixtures.values_at(:book, :wii),
                 :items => @items
               )

    assert response.success?

    assert_equal 4, response.rates.size

    assert rate = response.rates.first
    assert_equal "USPS Priority Mail", rate.service_name
    assert_equal nil, rate.service_code
    assert_equal "USPS", rate.carrier
    assert_equal 800, rate.total_price
    assert_equal ["UPS 2nd Day Air", "UPS Ground", "UPS Next Day Air Saver", "USPS Priority Mail"], response.rates.collect(&:service_name).sort
    assert_equal [800, 1234, 2186, 3605], response.rates.collect(&:total_price).sort
  end

  def test_maximum_address_field_length
    assert_equal 255, @carrier.maximum_address_field_length
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_shipping-1.8.6 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.5 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.4 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.3 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.2 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.8.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.7.3 test/unit/carriers/kunaki_test.rb
active_shipping-1.7.2 test/unit/carriers/kunaki_test.rb
active_shipping-1.7.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.7.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.5 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.4 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.3 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.2 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.6.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.5.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.4.3 test/unit/carriers/kunaki_test.rb
active_shipping-1.4.2 test/unit/carriers/kunaki_test.rb