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-3.0.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.4.3 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.0.beta1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.4.2 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.4.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.4.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.2.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.1.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.1.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.0.2 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.0.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-2.0.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.9.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.9.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.8.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.8.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.7.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.6.2 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-1.6.1 spec/formatters/numbers/helpers/fraction_spec.rb