Sha256: 7aabc4c400b1e735b15bfce7e53109b7dffe1e03819fc65182bd6990189c8723

Contents?: true

Size: 804 Bytes

Versions: 28

Compression:

Stored size: 804 Bytes

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Formatters::Numbers
include TwitterCldr::Tokenizers

describe Fraction do
  describe "#apply" do
    it "test: formats a fraction" do
      token = Token.new(:value => '###.##', :type => :pattern)
      Fraction.new(token).apply('45').should == '.45'
    end

    it "test: pads zero digits on the right side" do
      token = Token.new(:value => '###.0000#', :type => :pattern)
      Fraction.new(token).apply('45').should == '.45000'
    end

    it "test: :precision option overrides format precision" do
      token = Token.new(:value => '###.##', :type => :pattern)
      Fraction.new(token).apply('78901', :precision => 5).should == '.78901'
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
twitter_cldr-1.6.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.5.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.4.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.4.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.3.6 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.3.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.2.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.1.0 spec/formatters/numbers/helpers/fraction_spec.rb