Sha256: 41d0068f3aa08c42731db43fa252f4a0cdd8bad8fd5621bc16bc0bd582210ce4

Contents?: true

Size: 973 Bytes

Versions: 9

Compression:

Stored size: 973 Bytes

Contents

# encoding: utf-8

require 'helper'

class TestSSN < Test::Unit::TestCase

  def test_ssn_format
    ssn = Faker::SSNSE.ssn
    assert_match(/(19|20)\d{10}/, ssn, "With no arguments year should start with 19 or 20, #{ssn}")
  end

  def is_equal?(nbr)
    nbr % 2
  end

  def test_ssn_with_gender
    ssn_male = Faker::SSNSE.ssn(:gender => :male)
    assert is_equal?(ssn_male[10].to_i)

    ssn_female = Faker::SSNSE.ssn(:gender => :female)
    assert is_equal?(ssn_female[10].to_i)

    assert_raise ArgumentError do
      Faker::SSNSE.ssn(:gender => :unkown)
    end
  end

  def test_ssn_with_from_to
    10.times do
      from = Time.local(1980, 2, 28)
      to = Time.local(2000, 2, 28)

      ssn = Faker::SSNSE.ssn(:from => from, :to => to)
      year = ssn[0..3].to_i
      month = ssn[4..5].to_i
      day = ssn[6..7].to_i
      ssn_birth_date = Time.local(year, month, day)

      assert ssn_birth_date < to
      assert ssn_birth_date > from
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ffaker-1.31.0 test/test_ssn_se.rb
ffaker-1.30.0 test/test_ssn_se.rb
ffaker-1.25.0 test/test_ssn_se.rb
ffaker-1.24.0 test/test_ssn_se.rb
ffakerer-1.0.2 test/test_ssn_se.rb
ffaker-1.23.0 test/test_ssn_se.rb
ffakerer-1.0.1 test/test_ssn_se.rb
ffaker-1.22.1 test/test_ssn_se.rb
ffaker-1.22.0 test/test_ssn_se.rb