Sha256: 2358b03ee41b0dee46e82ad71b5d2c20a4147db84992ce0d2478d93b8494c361
Contents?: true
Size: 1.73 KB
Versions: 4
Compression:
Stored size: 1.73 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
4 entries across 4 versions & 1 rubygems