Skip to content

Commit

Permalink
Chore/improve pt-BR specs (#1548)
Browse files Browse the repository at this point in the history
* Improve pt-br address tests

* Fix and improve pt-br color methods

* Improve tests for email and license plate

* Use .match() method in tests
  • Loading branch information
paulodiovani authored and vbrazo committed Feb 21, 2019
1 parent 9ceb596 commit a9a3feb
Showing 1 changed file with 40 additions and 1 deletion.
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

0 comments on commit a9a3feb

Please sign in to comment.