Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/improve pt-BR specs #1548

Merged
merged 4 commits into from Feb 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 40 additions & 1 deletion test/test_pt_br_locale.rb
Expand Up @@ -13,20 +13,54 @@ def teardown

def test_pt_br_address_methods
assert Faker::Address.city.is_a? String

assert Faker::Address.state_abbr.is_a? String
assert Faker::Address.state_abbr.match(/^[A-Z]{2}$/)

assert Faker::Address.country.is_a? String

assert Faker::Address.building_number.is_a? String
assert Faker::Address.building_number.match(/^([0-9]+)|(s\/n)$/)

assert Faker::Address.street_suffix.is_a? String

assert Faker::Address.secondary_address.is_a? String
assert Faker::Address.secondary_address.match(/^[a-zA-Z\.]+\s[0-9]+$/)

assert Faker::Address.postcode.is_a? String
assert Faker::Address.postcode.match(/^[0-9]{5}\-[0-9]{3}$/)

assert Faker::Address.state.is_a? String
assert Faker::Address.city.is_a? String
assert Faker::Address.street_name.is_a? String
assert Faker::Address.default_country, 'Brasil'
end

def test_pt_br_color_methods
assert Faker::Color.name.is_a? String
assert Faker::Color.hex_color.is_a? String
assert Faker::Color.hex_color.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)

assert Faker::Color.color_name.is_a? String

assert Faker::Color.rgb_color.is_a? Array
Faker::Color.rgb_color.each do |value|
assert value >= 0 && value <= 255
end

assert Faker::Color.hsl_color.is_a? Array
hue = Faker::Color.hsl_color[0]
assert hue >= 0 && hue <= 360
Faker::Color.hsl_color[1..2].each do |value|
assert value >= 0 && value <= 1
end

assert Faker::Color.hsla_color.is_a? Array
assert Faker::Color.hsl_color.is_a? Array
hue = Faker::Color.hsl_color[0]
assert hue >= 0 && hue <= 360
Faker::Color.hsl_color[1..3].each do |value|
assert value >= 0 && value <= 1
end
end

def test_pt_br_company_methods
Expand All @@ -50,6 +84,8 @@ def test_pt_br_food_methods

def test_pt_br_internet_methods
assert Faker::Internet.free_email.is_a? String
assert Faker::Internet.free_email.match(/^[a-z0-9._\-]+@[a-z0-9]+.[a-z]+.([a-z]+)?$/i)

assert Faker::Internet.domain_suffix.is_a? String
end

Expand Down Expand Up @@ -93,7 +129,10 @@ def test_pt_br_university_methods

def test_pt_br_vehicle_methods
assert Faker::Vehicle.license_plate.is_a? String
assert Faker::Vehicle.license_plate.match(/^[A-Z]{3}\-[0-9]{4}/)

assert Faker::Vehicle.license_plate('RJ').is_a? String
assert Faker::Vehicle.license_plate('RJ').match(/^[A-Z]{3}\-[0-9]{4}/)
end

def test_pt_br_gender_methods
Expand Down