Sha256: 5b72434a3250e58d46c4e5672f2c7f93e5404700fa5fa354697ad7749007c8d7

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

# encoding: UTF-8

require File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "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

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-1.0.1 spec/formatters/numbers/currency_formatter_spec.rb