File: test_name_ga.rb

package info (click to toggle)
ruby-ffaker 2.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,776 kB
  • sloc: ruby: 12,788; makefile: 8; sh: 1
file content (61 lines) | stat: -rw-r--r-- 1,763 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true

require_relative 'helper'

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

  assert_methods_are_deterministic(
    FFaker::NameGA,
    :last_name, :first_name_male, :first_name_female, :name_male, :name_female, :name
  )

  def setup
    @tester = FFaker::NameGA
  end

  def test_last_name
    assert_include @tester::LAST_NAMES, @tester.last_name
  end

  def test_first_name_male
    assert_include @tester::FIRST_NAMES_MALE, @tester.first_name_male
  end

  def test_first_name_female
    assert_include @tester::FIRST_NAMES_FEMALE, @tester.first_name_female
  end

  def test_name_male
    # => split the name_male into an array of words
    first_name, last_name = @tester.name_male.split(' ')

    # the value at the index 0 should be a valid! male_prefix
    assert_include @tester::FIRST_NAMES_MALE, first_name

    # the value at the index 1 should be a valid! last_name
    assert_include @tester::LAST_NAMES, last_name
  end

  def test_name_female
    # => split the name_male into an array of words
    first_name, last_name = @tester.name_female.split(' ')

    # the value at the index 0 should be a valid! male_prefix
    assert_include @tester::FIRST_NAMES_FEMALE, first_name

    # the value at the index 1 should be a valid! last_name
    assert_include @tester::LAST_NAMES, last_name
  end

  def test_name
    # => split the name_male into an array of words
    first_name, last_name = @tester.name.split(' ')

    # the value at the index 0 should be a valid! male_prefix
    assert_include(@tester::FIRST_NAMES_FEMALE + @tester::FIRST_NAMES_MALE, first_name)

    # the value at the index 1 should be a valid! last_name
    assert_include @tester::LAST_NAMES, last_name
  end
end