Sha256: e176c2777364e29ad745052f83b54b0e23ae4cadca684aa39d95dd3d69695025

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Formatters

describe DecimalFormatter do
  before(:each) do
    @formatter = DecimalFormatter.new(:locale => :nl)
  end

  describe "#format" do
    it "should format positive decimals correctly" do
      @formatter.format(12.0).should == "12,0"
    end

    it "should format negative decimals correctly" do
      @formatter.format(-12.0).should == "-12,0"
    end

    it "should respect the :precision option" do
      @formatter.format(-12, :precision => 3).should == "-12,000"
    end
  end

  describe "#get_tokens" do
    it "should ask the tokenizer for the tokens for a positive number" do
      mock(@formatter.tokenizer).tokens(:sign => :positive) { true }
      @formatter.send(:get_tokens, 12)
    end

    it "should ask the tokenizer for the tokens for a negative number" do
      mock(@formatter.tokenizer).tokens(:sign => :negative) { true }
      @formatter.send(:get_tokens, -12)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-3.0.0.beta1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.4.2 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.4.1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.4.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.2.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.1.1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.1.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.0.2 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.0.1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-2.0.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-1.9.1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-1.9.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-1.8.1 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-1.8.0 spec/formatters/numbers/decimal_formatter_spec.rb
twitter_cldr-1.7.0 spec/formatters/numbers/decimal_formatter_spec.rb