Sha256: a66724efa86a5f0dd785b9344ad84f569b6fe68c6ab34251281eb9b008fc8ce8

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require 'helper'

class TestPhoneNumberBR < Test::Unit::TestCase
  include DeterministicHelper

  assert_methods_are_deterministic(
    FFaker::PhoneNumberBR,
    :phone_number, :home_work_phone_number, :mobile_phone_number,
    :international_phone_number, :international_mobile_phone_number,
    :international_home_work_phone_number, :country_code
  )

  def setup
    @tester = FFaker::PhoneNumberBR
  end

  def test_area_codes
    assert(!@tester::AREA_CODE.empty?)
    assert(@tester::AREA_CODE.sort.uniq == @tester::AREA_CODE)
    @tester::AREA_CODE.each do |area_code|
      assert_match(/\A[1-9]\d\z/, area_code)
    end
  end

  def test_phone_number
    10.times do
      assert_match(/\A[1-9]\d\s?9?\d{4}-?\d{4}\z/, @tester.phone_number)
    end
  end

  def test_home_work_phone_number
    assert_match(/\A[1-9]\d\s?[2-5]\d{3}-?\d{4}\z/,
                 @tester.home_work_phone_number)
  end

  def test_mobile_phone_number
    assert_match(/\A[1-9]\d\s?9[6-9]\d{3}-?\d{4}\z/,
                 @tester.mobile_phone_number)
  end

  def test_international_phone_number
    10.times do
      assert_match(/\A\+55\s?[1-9]\d\s?9?\d{4}-?\d{4}\z/,
                   @tester.international_phone_number)
    end
  end

  def test_international_mobile_phone_number
    assert_match(/\A\+55\s?[1-9]\d\s?9[6-9]\d{3}-?\d{4}\z/,
                 @tester.international_mobile_phone_number)
  end

  def test_international_home_work_phone_number
    assert_match(/\A\+55\s?[1-9]\d\s?[2-5]\d{3}-?\d{4}\z/,
                 @tester.international_home_work_phone_number)
  end

  def test_country_code
    assert_match('+55', @tester.country_code)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ffaker-2.18.0 test/test_phone_number_br.rb
ffaker-2.17.0 test/test_phone_number_br.rb
ffaker-2.16.0 test/test_phone_number_br.rb
ffaker-2.15.0 test/test_phone_number_br.rb
ffaker-2.14.0 test/test_phone_number_br.rb
ffaker-2.13.0 test/test_phone_number_br.rb
ffaker-2.12.0 test/test_phone_number_br.rb