Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions test/faker/default/test_faker_id_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_invalid_south_african_id_number
sample = @tester.invalid_south_african_id_number

assert_raises Date::Error do
Date.parse(south_african_id_number_to_date_of_birth_string(sample))
Date.parse(sample[0..5])
end
end

Expand Down Expand Up @@ -276,15 +276,12 @@ def test_danish_id_number_invalid_gender

private

def south_african_id_number_to_date_of_birth_string(sample)
"19#{sample[0..1]}/#{sample[2..3]}/#{sample[4..5]}}"
end

def assert_valid_south_african_id_number(sample)
assert_equal 13, sample.length
assert_match(/^\d{13}$/, sample)
assert_include Faker::IdNumber::ZA_CITIZENSHIP_DIGITS, sample[10]
assert_equal Faker::IdNumber::ZA_RACE_DIGIT, sample[11]
assert Date.parse(south_african_id_number_to_date_of_birth_string(sample))

assert Date.parse(sample[0..5])
end
end