Sha256: 3dfcaabf252bc8726d655ef072c7429314294a42e0777bf75abc71abdf5e7ab1

Contents?: true

Size: 819 Bytes

Versions: 17

Compression:

Stored size: 819 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)
      expect(Fraction.new(token).apply('45')).to eq('.45')
    end

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

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

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/spec/formatters/numbers/helpers/fraction_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/spec/formatters/numbers/helpers/fraction_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.2.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.2.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.1.2 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.1.1 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.1.0 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.10 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.9 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.8 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.7 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.6 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.5 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.4 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.3 spec/formatters/numbers/helpers/fraction_spec.rb
twitter_cldr-3.0.2 spec/formatters/numbers/helpers/fraction_spec.rb