Sha256: 754b820851da826a5d8587bf5bb5544191bc63fae3cc64e83d11b03a30c7827d

Contents?: true

Size: 1.7 KB

Versions: 62

Compression:

Stored size: 1.7 KB

Contents

require 'test_helper'

class RemoteCanadaPostTest < ActiveSupport::TestCase
  include ActiveShipping::Test::Credentials

  def setup
    @carrier        = CanadaPost.new(credentials(:canada_post))
    @french_carrier = CanadaPost.new(credentials(:canada_post).merge(french: true))

    @origin      = { address1: "61A York St", city: "Ottawa", province: "Ontario", country: "Canada", postal_code: "K1N 5T2" }
    @destination = { city: "Beverly Hills", state: "CA", country: "United States", postal_code: "90210" }
    @line_items  = [Package.new(500, [2, 3, 4], description: "a box full of stuff", value: 25)]
  rescue NoCredentialsFound => e
    skip(e.message)
  end

  def test_valid_credentials
    assert @carrier.valid_credentials?
  end

  def test_find_rates_french
    rates = @french_carrier.find_rates(@origin, @destination, @line_items)
    assert_instance_of CanadaPost::CanadaPostRateResponse, rates
  end

  def test_postal_outlets_french
    rates = @french_carrier.find_rates(@origin, @destination, @line_items)

    rates.postal_outlets.each do |outlet|
      assert_instance_of CanadaPost::PostalOutlet, outlet
    end
  end

  def test_find_rates
    rates = @carrier.find_rates(@origin, @destination, @line_items)
    assert_instance_of CanadaPost::CanadaPostRateResponse, rates
  end

  def test_postal_outlets
    rates = @carrier.find_rates(@origin, @destination, @line_items)

    rates.postal_outlets.each do |outlet|
      assert_instance_of CanadaPost::PostalOutlet, outlet
    end
  end

  def test_illegal_origin
    @origin = @destination

    assert_raises(ActiveShipping::ResponseError) do
      rates = @carrier.find_rates(@origin, @destination, @line_items)
      refute rates.success?
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.26 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.45 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.25 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.23 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.44 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.22 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.43 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.21 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.42 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.20 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.41 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.19 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.40 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.18 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.39 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.17 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.38 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.5.16 vendor/active_shipping/test/remote/canada_post_test.rb
workarea-core-3.4.37 vendor/active_shipping/test/remote/canada_post_test.rb