Sha256: 2a445d616ec51af7d944bca50010a4693f3e62c1fd6e9d713ac53c0e731fdcea

Contents?: true

Size: 1.12 KB

Versions: 39

Compression:

Stored size: 1.12 KB

Contents

require 'test_helper'

class CurrencyCodeTest < Minitest::Test
  def test_is_iso_should_return_true_for_iso_currencies
    assert CurrencyCode.is_iso?('CAD')
    assert CurrencyCode.is_iso?('USD')
    assert CurrencyCode.is_iso?('TWD')
  end

  def test_is_iso_should_return_false_for_non_iso_currencies
    assert !CurrencyCode.is_iso?('NTD')
    assert !CurrencyCode.is_iso?('RMB')
  end

  def test_standardize_should_not_change_iso_currencies
    assert_equal 'CAD', CurrencyCode.standardize('CAD')
    assert_equal 'USD', CurrencyCode.standardize('usd')
    assert_equal 'TWD', CurrencyCode.standardize('TWD')
  end

  def test_standardize_should_convert_known_non_iso_to_iso
    assert_equal 'TWD', CurrencyCode.standardize('NTD')
    assert_equal 'CNY', CurrencyCode.standardize('rmb')
  end

  def test_standardize_should_raise_for_unknwon_currencies
    assert_raises CurrencyCode::InvalidCurrencyCodeError do
      CurrencyCode.standardize('Not Real')
    end
  end

  def test_nil_code_should_raise_InvalidCurrencyCodeError
    assert_raises CurrencyCode::InvalidCurrencyCodeError do
      CurrencyCode.standardize(nil)
    end
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
active_utils-3.4.1 test/unit/currency_code_test.rb
active_utils-3.4.0 test/unit/currency_code_test.rb
active_utils-3.3.19 test/unit/currency_code_test.rb
active_utils-3.3.18 test/unit/currency_code_test.rb
active_utils-3.3.17 test/unit/currency_code_test.rb
active_utils-3.3.16 test/unit/currency_code_test.rb
active_utils-3.3.15 test/unit/currency_code_test.rb
active_utils-3.3.14 test/unit/currency_code_test.rb
active_utils-3.3.13 test/unit/currency_code_test.rb
active_utils-3.3.12 test/unit/currency_code_test.rb
active_utils-3.3.11 test/unit/currency_code_test.rb
active_utils-3.3.10 test/unit/currency_code_test.rb
active_utils-3.3.9 test/unit/currency_code_test.rb
active_utils-3.3.8 test/unit/currency_code_test.rb
active_utils-3.3.7 test/unit/currency_code_test.rb
active_utils-3.3.6 test/unit/currency_code_test.rb
active_utils-3.3.5 test/unit/currency_code_test.rb
active_utils-3.3.4 test/unit/currency_code_test.rb
active_utils-3.3.3 test/unit/currency_code_test.rb
active_utils-3.3.2 test/unit/currency_code_test.rb