Sha256: a145ee9bfaf82e2603178d4a8e45002fe055e937f07a4efcf9704620dc095517

Contents?: true

Size: 972 Bytes

Versions: 10

Compression:

Stored size: 972 Bytes

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Formatters

describe CurrencyFormatter do
  describe "#format" do
    before(:each) do
      @formatter = CurrencyFormatter.new(:locale => :msa)
    end

    it "should use a dollar sign when no other currency symbol is given (and default to a precision of 2)" do
      @formatter.format(12).should == "$12.00"
    end

    it "should use the specified currency symbol when specified" do
      # S/. is the symbol for the Peruvian Nuevo Sol, just in case you were curious
      @formatter.format(12, :currency => "S/.").should == "S/.12.00"
    end

    it "should use the currency symbol for the corresponding currency code" do
      @formatter.format(12, :currency => "PEN").should == "S/.12.00"
    end

    it "overrides the default precision" do
      @formatter.format(12, :precision => 3).should == "$12.000"
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
twitter_cldr-1.6.2 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.6.1 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.6.0 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.5.0 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.4.1 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.4.0 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.3.6 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.3.0 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.2.0 spec/formatters/numbers/currency_formatter_spec.rb
twitter_cldr-1.1.0 spec/formatters/numbers/currency_formatter_spec.rb