Sha256: 66c846e5b303d26aae73a8c540e08752af5077b8d6d27e241278a9262ed2ff7c

Contents?: true

Size: 1.49 KB

Versions: 67

Compression:

Stored size: 1.49 KB

Contents

require 'test_helper'

class CanadaPostPwsTest < ActiveSupport::TestCase

  def setup
    credentials = { platform_id: 123, api_key: '456', secret: '789' }
    @cp = CanadaPostPWS.new(credentials)
  end

  def test_get_sanitized_postal_code_location_nil
    postal_code = @cp.send(:get_sanitized_postal_code, nil)

    assert_equal nil, postal_code
  end

  def test_get_sanitized_postal_code_postal_code_nil
    location = Location.new(name: 'Test test')

    assert_equal nil, location.postal_code

    postal_code = @cp.send(:get_sanitized_postal_code, location)

    assert_equal nil, postal_code
  end

  def test_get_sanitized_postal_code_spaces
    location = Location.new(postal_code: '    K2P     1L4    ')

    postal_code = @cp.send(:get_sanitized_postal_code, location)

    assert_equal 'K2P1L4', postal_code
  end

  def test_get_sanitized_postal_code_lowercase
    location = Location.new(postal_code: 'k2p 1l4')

    postal_code = @cp.send(:get_sanitized_postal_code, location)

    assert_equal 'K2P1L4', postal_code
  end

  def test_get_sanitzied_postal_code_proper
    location = Location.new(postal_code: 'K2P1L4')

    postal_code = @cp.send(:get_sanitized_postal_code, location)

    assert_equal 'K2P1L4', postal_code
  end

  def test_get_sanitzied_postal_code_does_not_alter_original
    location = Location.new(postal_code: 'K2P  1l4')

    assert_equal 'K2P  1l4', location.postal_code

    @cp.send(:get_sanitized_postal_code, location)

    assert_equal 'K2P  1l4', location.postal_code
  end
end

Version data entries

67 entries across 67 versions & 3 rubygems

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