Sha256: 645a0bda31d666e042414d4a5eba93b9f5315168ba8db661baea50cf47f731b9

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

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 TwitterCldr::Shared::Currencies do
  describe "#currency_codes" do
    it "should list all supported country codes" do
      codes = described_class.currency_codes

      expect(codes.size).to eq(303)
      expect(codes).to include(*TEST_CODES)
    end
  end

  describe "#for_code" do
    it "should return all information for PEN" do
      data = described_class.for_code("PEN")
      expect(data).to be_a(Hash)
      expect(data).to include(
        name:        "Peruvian 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 = described_class.for_code("CAD")
      expect(data).to be_a(Hash)
      expect(data).to 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
      described_class.currency_codes.select do |code|
        data = described_class.for_code(code)
        expect(data[:code_points].pack("U*")).to eq(data[:symbol])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter_cldr-6.11.5 spec/shared/currencies_spec.rb
twitter_cldr-6.11.4 spec/shared/currencies_spec.rb
twitter_cldr-6.11.3 spec/shared/currencies_spec.rb