Sha256: 1c9f5b47230c2355384561a7dc77f189f14cd0e5519a9c35166439dd7f3ae686

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr::Shared

TEST_COUNTRIES = ["Australia", "Thailand", "Russia", "China", "Japan", "Peru", "South Africa", "India", "South Korea", "United Kingdom"]
TEST_CODES     = %w[AUD THB RUB CNY JPY PEN ZAR INR KRW GBP]

describe Currencies do
  describe "#currency_codes" do
    it "should list all supported country codes" do
      codes = Currencies.currency_codes

      codes.size.should == 297
      codes.should include(*TEST_CODES)
    end
  end

  describe "#for_code" do
    it "should return all information for PEN" do
      data = Currencies.for_code("PEN")
      data.should be_a(Hash)
      data.should include(
        :name        => "Peruvian nuevo sol",
        :currency    => :PEN,
        :symbol      => "S/.",
        :cldr_symbol => "PEN"
      )
    end

    it "should return all information for CAD, a currency code with multiple possible symbols" do
      data = Currencies.for_code("CAD")
      data.should be_a(Hash)
      data.should include(
        :name        => "Canadian dollar",
        :currency    => :CAD,
        :symbol      => "$",
        :cldr_symbol => "CA$"
      )
    end

    it "verifies that all code_points values are equivalent to their corresponding symbols" do
      Currencies.currency_codes.select do |code|
        data = Currencies.for_code(code)
        data[:code_points].pack("U*").should == data[:symbol]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
twitter_cldr-3.0.1 spec/shared/currencies_spec.rb
twitter_cldr-2.4.3 spec/shared/currencies_spec.rb
twitter_cldr-3.0.0 spec/shared/currencies_spec.rb
twitter_cldr-3.0.0.beta1 spec/shared/currencies_spec.rb
twitter_cldr-2.4.2 spec/shared/currencies_spec.rb
twitter_cldr-2.4.1 spec/shared/currencies_spec.rb
twitter_cldr-2.4.0 spec/shared/currencies_spec.rb