File: test_country_code.rb

package info (click to toggle)
ruby-faker 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,596 kB
  • sloc: ruby: 20,656; sh: 6; makefile: 6
file content (33 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require_relative '../../test_helper'

class TestCountryCode < Test::Unit::TestCase
  def setup
    @previous_locale = Faker::Config.locale
    Faker::Config.locale = 'en'
  end

  def teardown
    Faker::Config.locale = @previous_locale
  end

  def test_country_code_expected_length
    assert_equal(2, Faker::Address.country_code.length)
  end

  def test_country_code_long_expected_length
    assert_equal(3, Faker::Address.country_code_long.length)
  end

  def test_all_country_code_have_country
    codes = Faker::Base.fetch_all('address.country_code')
    lonely_codes = codes.reject do |code|
      Faker::Address.country_by_code(code: code)
    rescue I18n::MissingTranslationData
      nil
    end

    assert_empty(lonely_codes)
  end
end