Sha256: a86d8c9af4196c4298cd2cea747575d1ecb35db04b90477a86dcd74cbc4f1ebd

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::DataReaders

describe NumberDataReader do
  let(:data_reader) { NumberDataReader.new(:en) }

  describe "#get_key_for" do
    it "builds a power-of-ten key based on the number of digits in the input" do
      (3..15).each { |i| expect(data_reader.send(:get_key_for, "1337#{"0" * (i - 3)}")).to eq(10 ** i) }
    end
  end

  describe "#pattern" do
    let(:symbols) { { :nan => 'NaN', :minus_sign => '<->' } } # unique locale-specific minus sign

    before(:each) do
      stub(TwitterCldr).get_locale_resource(:en, :numbers) {
        {
          :en => {
            :numbers => {
              :formats => { :decimal => { :patterns => { :default => "#,##0.###" } } },
              :symbols => symbols
            }
          }
        }
      }
    end

    it "returns pattern for a number" do
      expect(data_reader.pattern(2)).to eq("#,##0.###")
    end

    it "returns pattern for a negative number" do
      expect(data_reader.pattern(-2)).to eq("<->#,##0.###")
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/spec/data_readers/number_data_reader_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/spec/data_readers/number_data_reader_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/spec/data_readers/number_data_reader_spec.rb
twitter_cldr-3.2.1 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-3.2.0 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-3.1.2 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-3.1.1 spec/data_readers/number_data_reader_spec.rb
twitter_cldr-3.1.0 spec/data_readers/number_data_reader_spec.rb