Sha256: 00e7fc8596c402fc55b75406250b265a3b25946b6f17d0f60b8cc0e322c0a0b9

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

require 'spec_helper'

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

  tests = [
    [8.15, 'Acht Punkt Eins Fünf'],
    [1002, 'Eins Tausend und Zwei'],
    [2001, 'Zwei Tausend und Eins'],
    [10_000, 'Zehn Tausend']
  ]

  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('Acht Punkt Fünfzehn')
    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('Unendlich')
      expect(neg_inf.humanize).to eql('negativ Unendlich')
      expect(nan.humanize).to eql('Undefiniert')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
humanize-2.1.0 spec/locales/de_spec.rb
humanize-2.0.0 spec/locales/de_spec.rb