Sha256: babc18fea67a522bf7525bfe642b552d9e08a444ef0338e51f57c24b255645ea

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

require 'helper'

# Author: PapePathe<pathe.sene@gmail.com> github.com/PapePathe
class TestFakerNameIT < Test::Unit::TestCase
  def setup
    @tester = FFaker::NameIT
  end

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

  def test_first_name
    assert_include @tester::FIRST_NAMES, @tester.first_name
  end

  def test_prefix
    assert_include @tester::PREFIX, @tester.prefix
  end

  def test_name
    # => split the name into an array of words
    parts = @tester.name.split(' ')

    case parts.count
    when 3
      prefix, first_name, last_name = parts
      # the value at the index 0 should be a valid! prefix
      assert_include @tester::PREFIX, prefix

      # the value at the index 1 should be a valid! first_name
      assert_include @tester::FIRST_NAMES, first_name

      # the value at the index 2 should be a valid! last_name
      assert_include @tester::LAST_NAMES, last_name
    when 2
      first_name, last_name = parts
      # the value at the index 0 should be a valid! first_name
      assert_include @tester::FIRST_NAMES, first_name

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffaker-2.2.0 test/test_name_it.rb
ffaker-2.1.0 test/test_name_it.rb