Sha256: 84c717f020554d786f846e5aa0f55b06ce37344b1f2807799c583a9946dbea80

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

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

  tests = [
    [8.15, 'แปด จุด หนึ่ง ห้า'],
    [1002, 'หนึ่ง พัน และ สอง'],
    [2001, 'สอง พัน และ หนึ่ง'],
    [10_000, 'หนึ่ง หมื่น']
  ]

  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('แปด จุด สิบห้า')
    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('ความไม่มีที่สิ้นสุด')
      expect(neg_inf.humanize).to eql('เชิงลบ ความไม่มีที่สิ้นสุด')
      expect(nan.humanize).to eql('ไม่ได้กำหนด')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
humanize-2.1.2 spec/locales/th_spec.rb
humanize-2.1.1 spec/locales/th_spec.rb
humanize-2.1.0 spec/locales/th_spec.rb
humanize-2.0.0 spec/locales/th_spec.rb