Sha256: 6d12d6e9dce07cba2bd9ffb6d931f68fd491512ce01a8743decf912c3e338900

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_shipping-1.2.2 test/unit/carriers/kunaki_test.rb
active_shipping-1.2.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.2.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.1.3 test/unit/carriers/kunaki_test.rb
active_shipping-1.1.2 test/unit/carriers/kunaki_test.rb
active_shipping-1.1.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.1.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.0.1 test/unit/carriers/kunaki_test.rb
active_shipping-1.0.0 test/unit/carriers/kunaki_test.rb
active_shipping-1.0.0.pre4 test/unit/carriers/kunaki_test.rb
active_shipping-1.0.0.pre3 test/unit/carriers/kunaki_test.rb