Skip to content

Commit

Permalink
correct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoLira committed Aug 24, 2023
1 parent eabb008 commit a4720da
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 52 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
## Unreleased

### Added

- `Faker.Fruits.En` - add english fruits [[@KevinDaSilvaS](https://github.com/KevinDaSilvaS)]
- `Faker.Person.PtBr.female_first_name` - add Brazilian Portuguese female first name generator [[@FranciscoLira](https://github.com/FranciscoLira)]
- `Faker.Person.PtBr.male_first_name` - add Brazilian Portuguese male first name generator [[@FranciscoLira](https://github.com/FranciscoLira)]
- `Faker.Person.PtBr.female_prefix` - add Brazilian Portuguese female prefix generator [[@FranciscoLira](https://github.com/FranciscoLira)]
- `Faker.Person.PtBr.male_prefix` - add Brazilian Portuguese male prefix generator [[@FranciscoLira](https://github.com/FranciscoLira)]

### Changed

- `Faker.Commerce.PtBr` - add more products in product_name_product [[@igorgbr](https://github.com/igorgbr)]
- `Faker.Fruits.PtBr` - fix typo in nectarina [[@KevinDaSilvaS](https://github.com/KevinDaSilvaS)]
- `Faker.Internet.image_url/0` - switched unresponsive placeholder.it with picsum.photos [[@almirsarajcic](https://github.com/almirsarajcic)]
- `Faker.Vehicle.En` - fix spelling of some common makes/models [[@nskins](https://github.com/nskins)]
- `Faker.Person.PtBr.first_name` - separate male from female names. [[@FranciscoLira](https://github.com/FranciscoLira)]

### Deprecated

### Removed

### Fixed

- `Faker.Currency.code/0` remove duplicates/replace old currencies [[@yassinrais](https://github.com/yassinrais)]
- `Faker.Adress.PtBr` - fix model documentation [[@laraujo7](https://github.com/laraujo7)]
- `Faker.Address.En/0` corrected formatting for US and Britian [[@atavistock](https://github.com/atavistock)]
Expand All @@ -31,6 +39,7 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
## 0.17.0

### Added

- `Faker.Internet.StatusCode` [[@emmetreza](https://github.com/emmetreza)]
- CI workflow using GitHub Actions [[@anthonator](https://github.com/anthonator)]
- `Faker.Cat.PtBr` [[@f-francine](https://github.com/f-francine)]
Expand All @@ -39,20 +48,23 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
- `Faker.Commerce.PtBr` [[@f-francine](https://github.com/f-francine)]

### Changed

- `Faker.Vehicles` add makes and models that are multi-word, refactor existing fns [[jersearls](https://github.com/jersearls)]
- `Faker.Avatar` switch to `https` to prevent redirect [[igas](https://github.com/igas)]
- Updated build badge for GitHub Actions [[@anthonator](https://github.com/anthonator)]

### Deprecated

### Removed

- Travis CI for CI workflow [[@anthonator](https://github.com/anthonator)]

### Fixed

- `Faker.Team` `creature/0` and `name/0` documentation examples fixed [[@yuriploc](https://github.com/yuriploc)]
- Fix bidirectional formatting [[@MichalDolata](https://github.com/MichalDolata)]
- Extra split for Virgin Islands in the country sampler [[intercaetera](https://github.com/intercaetera)]

### Security

## 0.16.0
Expand Down Expand Up @@ -127,6 +139,7 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
- `Faker.Phone.PtBr`[[@netond](https://github.com/netond)]

### Changed

- Fix `Faker.Code.Iban.iban` and `Faker.Gov.It.fiscal_id` doctests [[@vbrazo](https://github.com/vbrazo)]
- `Faker.Address.Es` [[@emig](https://github.com/emig)]
- Set minimum Elixir version to 1.6
Expand All @@ -145,6 +158,7 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.
- Elixir 1.4 and 1.5 support

### Fixed

- `Faker.Util.upper_letter/0` documentation examples [[@michaelfich](https://github.com/michaelfich)]

### Security
Expand Down
2 changes: 1 addition & 1 deletion lib/faker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Faker do
acc
end

@alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
@alphabet ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
defp letter do
Enum.at(@alphabet, random_between(0, Enum.count(@alphabet) - 1))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Faker.Address do

alias Faker.Person

@geobase32 '0123456789bcdefghjkmnpqrstuvwxyz'
@geobase32 ~c"0123456789bcdefghjkmnpqrstuvwxyz"

@moduledoc """
Functions for generating addresses.
Expand Down
32 changes: 16 additions & 16 deletions lib/faker/address/pt_br.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ defmodule Faker.Address.PtBr do
## Examples
iex> Faker.Address.PtBr.city()
"Senador Kaique Paulista"
"Senador Suélen das Pedras"
iex> Faker.Address.PtBr.city()
"São Roberta dos Dourados"
"São Pedro Lucas do Sul"
iex> Faker.Address.PtBr.city()
"Salto das Flores"
"Três Pedro Henrique"
iex> Faker.Address.PtBr.city()
"Kléber"
"João Gabriel Alegre"
"""
@spec city() :: String.t()
def city do
Expand Down Expand Up @@ -1034,13 +1034,13 @@ defmodule Faker.Address.PtBr do
## Examples
iex> Faker.Address.PtBr.street_address()
"Estação Kaique, 2"
"Estação Suélen, 646"
iex> Faker.Address.PtBr.street_address()
"Lagoa Matheus, 0832"
"Recanto Arthur, 970"
iex> Faker.Address.PtBr.street_address()
"Estrada Diegues, s/n"
"Trecho Júlia Viana, s/n"
iex> Faker.Address.PtBr.street_address()
"Praia Limeira, 020"
"Passarela Morais, s/n"
"""
@spec street_address() :: String.t()
def street_address do
Expand All @@ -1053,13 +1053,13 @@ defmodule Faker.Address.PtBr do
## Examples
iex> Faker.Address.PtBr.street_address(true)
"Estação Kaique, 2 Sala 461"
"Estação Suélen, 646 AP 083"
iex> Faker.Address.PtBr.street_address(false)
"Conjunto Rodrigo, 970"
"Setor da Penha, s/n"
iex> Faker.Address.PtBr.street_address(false)
"Trecho Davi Luiz Limeira, 020"
"Trecho Júlia Viana, s/n"
iex> Faker.Address.PtBr.street_address(false)
"Sítio Maria Eduarda, 097"
"Passarela Morais, s/n"
"""
@spec street_address(true | any) :: String.t()
def street_address(true), do: street_address() <> " " <> secondary_address()
Expand All @@ -1071,13 +1071,13 @@ defmodule Faker.Address.PtBr do
## Examples
iex> Faker.Address.PtBr.street_name()
"Estação Kaique"
"Estação Suélen"
iex> Faker.Address.PtBr.street_name()
"Morro Louise Macieira"
"Colônia Macieira"
iex> Faker.Address.PtBr.street_name()
"Loteamento Maria Alice Junqueira"
"Loteamento Emanuel Albuquerque"
iex> Faker.Address.PtBr.street_name()
"Condomínio da Maia"
"Setor da Penha"
"""
@spec street_name() :: String.t()
def street_name do
Expand Down
20 changes: 10 additions & 10 deletions lib/faker/file.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ defmodule Faker.File do
## Examples
iex> Faker.File.file_extension()
"wav"
"txt"
iex> Faker.File.file_extension()
"wav"
"html"
iex> Faker.File.file_extension()
"doc"
"flac"
iex> Faker.File.file_extension()
"mov"
"odt"
"""
@spec file_extension() :: String.t()
def file_extension do
Expand Down Expand Up @@ -84,11 +84,11 @@ defmodule Faker.File do
iex> Faker.File.file_name()
"aliquam.jpg"
iex> Faker.File.file_name()
"deleniti.doc"
"deleniti.flac"
iex> Faker.File.file_name()
"qui.jpg"
iex> Faker.File.file_name()
"quibusdam.csv"
"quibusdam.webm"
"""
@spec file_name() :: String.t()
def file_name do
Expand Down Expand Up @@ -121,13 +121,13 @@ defmodule Faker.File do
## Examples
iex> Faker.File.mime_type()
"text/css"
"model/mesh"
iex> Faker.File.mime_type()
"message/http"
"image/tiff"
iex> Faker.File.mime_type()
"application/ogg"
"message/partial"
iex> Faker.File.mime_type()
"model/x3d+xml"
"audio/webm"
"""
@spec mime_type :: String.t()
def mime_type do
Expand Down
2 changes: 1 addition & 1 deletion lib/faker/lorem.ex
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ defmodule Faker.Lorem do
end

defp character do
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
alphabet = ~c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Enum.at(alphabet, Faker.random_between(0, Enum.count(alphabet) - 1))
end
end
44 changes: 24 additions & 20 deletions lib/faker/person/pt_br.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ defmodule Faker.Person.PtBr do
## Examples
iex> Faker.Person.PtBr.name()
"Sra. Kaique Mendes Neto"
"Dr. Hélio Mendes Neto"
iex> Faker.Person.PtBr.name()
"Roberta Garcês"
"Bernardo Mangueira"
iex> Faker.Person.PtBr.name()
"Sr. Vitor Albuquerque"
"Sr. Arthur Santana Neto"
iex> Faker.Person.PtBr.name()
"Maria Laura da Penha Jr."
"João Gabriel Resende"
"""
@spec name() :: String.t()
def name, do: name(Faker.random_between(0, 9))
def name, do: name(Faker.random_between(0, 12))
defp name(0), do: "#{male_prefix()} #{male_first_name()} #{last_name()} #{suffix()}"
defp name(1), do: "#{male_prefix()} #{male_first_name()} #{last_name()}"
defp name(2), do: "#{male_first_name()} #{last_name()} #{suffix()}"
defp name(3), do: "#{male_first_name()} #{last_name()}"
defp name(4), do: "#{female_prefix()} #{female_first_name()} #{last_name()}"
defp name(5), do: "#{female_first_name()} #{last_name()}"

defp name(i) when i == 4 or i == 5,
do: "#{female_prefix()} #{female_first_name()} #{last_name()}"

defp name(i) when i == 6 or i == 7,
do: "#{female_first_name()} #{last_name()}"

defp name(n) when is_integer(n) do
"#{first_name()} #{last_name()}"
Expand All @@ -38,16 +42,16 @@ defmodule Faker.Person.PtBr do
## Examples
iex> Faker.Person.PtBr.first_name()
"Augusto"
"Luiz Henrique"
iex> Faker.Person.PtBr.first_name()
"Amanda"
"Suélen"
iex> Faker.Person.PtBr.first_name()
"Kaique"
"Arthur Henrique"
iex> Faker.Person.PtBr.first_name()
"Antonia"
"Bernardo"
"""
@spec first_name() :: String.t()
def first_name, do: first_name(Faker.random_between(0, 1))
def first_name(), do: first_name(Faker.random_between(0, 1))
defp first_name(0), do: "#{male_first_name()}"
defp first_name(1), do: "#{female_first_name()}"

Expand All @@ -57,13 +61,13 @@ defmodule Faker.Person.PtBr do
## Examples
iex> Faker.Person.PtBr.male_first_name()
"Augusto"
"Bruno"
iex> Faker.Person.PtBr.male_first_name()
"Benjamin"
"Luiz Henrique"
iex> Faker.Person.PtBr.male_first_name()
"Kaique"
"Hélio"
iex> Faker.Person.PtBr.male_first_name()
"Frederico"
"Mathias"
"""
@spec male_first_name() :: String.t()
sampler(:male_first_name, [
Expand Down Expand Up @@ -215,13 +219,13 @@ defmodule Faker.Person.PtBr do
## Examples
iex> Faker.Person.PtBr.female_first_name()
"Luna"
"Maria Helena"
iex> Faker.Person.PtBr.female_first_name()
"Amanda"
"Alessandra"
iex> Faker.Person.PtBr.female_first_name()
"Maria Isis"
"Ayla"
iex> Faker.Person.PtBr.female_first_name()
"Antonia"
"Suélen"
"""

@spec female_first_name() :: String.t()
Expand Down
6 changes: 3 additions & 3 deletions lib/faker/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ defmodule Faker.Util do
iex> Faker.Util.sample_uniq(0, &Faker.Internet.email/0)
** (FunctionClauseError) no function clause matching in Faker.Util.sample_uniq/3
"""
@spec sample_uniq(pos_integer, (() -> any), MapSet.t()) :: [any]
@spec sample_uniq(pos_integer, (-> any), MapSet.t()) :: [any]
def sample_uniq(count, sampler, acc \\ MapSet.new())
when is_integer(count) and count > 0 and is_function(sampler, 0) do
case MapSet.size(acc) do
Expand Down Expand Up @@ -84,7 +84,7 @@ defmodule Faker.Util do
Enum.map(0..(n - 1), &fun.(&1))
end

@spec list(integer, (() -> any)) :: [any]
@spec list(integer, (-> any)) :: [any]
def list(n, fun) when is_function(fun, 0) do
Enum.map(0..(n - 1), fn _ -> fun.() end)
end
Expand All @@ -103,7 +103,7 @@ defmodule Faker.Util do
iex> Faker.Util.join(2, " or ", &Faker.Color.name/0)
"Purple or White"
"""
@spec join(integer, binary, (() -> binary)) :: binary
@spec join(integer, binary, (-> binary)) :: binary
def join(n, joiner \\ "", fun) do
Enum.join(list(n, fun), joiner)
end
Expand Down

0 comments on commit a4720da

Please sign in to comment.