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.15 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.36 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.14 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.35 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.13 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.34 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.12 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.33 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.11 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.10 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.32 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.9 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.31 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.8 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.30 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.7 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.29 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.6 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.4.28 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb
workarea-core-3.5.5 vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb