Sha256: c3fc4fda2330fe0c08d6387ec9947009dfc80163e4d3b100c9751d5a52b2aa03

Contents?: true

Size: 978 Bytes

Versions: 9

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

RSpec.describe Humanize, "pt locale" do
  before do
    Humanize.configure do |config|
      config.default_locale = :pt
    end
  end

  tests = [
    [8.15, 'oito vírgula um cinco'],
    [1000, 'mil'],
    [1002, 'mil e dois'],
    [2000, 'dois mil'],
    [2002, 'dois mil e dois'],
    [10_000, 'dez mil']
  ]

  tests.each do |num, output|
    it "#{num} equals #{output}" do
      expect(num.humanize).to eql(output)
    end
  end

  context 'decimals: number' do
    it 'returns the decimals as whole numbers' do
      num = 8.15
      expect(num.humanize(decimals_as: :number)).to eq('oito vírgula quinze')
    end
  end

  describe 'when called on conceptual number' do
    it 'reads correctly' do
      inf = Float::INFINITY
      neg_inf = -inf
      nan = inf + neg_inf

      expect(inf.humanize).to eql('infinito')
      expect(neg_inf.humanize).to eql('negativo infinito')
      expect(nan.humanize).to eql('indefinido')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
humanize-3.0.0 spec/locales/pt_spec.rb
humanize-2.5.1 spec/locales/pt_spec.rb
humanize-2.5.0 spec/locales/pt_spec.rb
humanize-2.4.3 spec/locales/pt_spec.rb
humanize-2.4.2 spec/locales/pt_spec.rb
humanize-2.4.1 spec/locales/pt_spec.rb
humanize-2.4.0 spec/locales/pt_spec.rb
humanize-2.3.0 spec/locales/pt_spec.rb
humanize-2.2.1 spec/locales/pt_spec.rb