laranja 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +6 -0
- data/laranja.gemspec +26 -0
- data/lib/laranja.rb +31 -0
- data/lib/laranja/cpf.rb +24 -0
- data/lib/laranja/internet.rb +26 -0
- data/lib/laranja/name.rb +25 -0
- data/lib/laranja/version.rb +3 -0
- data/lib/static_data.yml +9 -0
- data/spec/cpf_spec.rb +62 -0
- data/spec/internet_spec.rb +77 -0
- data/spec/name_spec.rb +58 -0
- data/spec/spec_helper.rb +5 -0
- metadata +139 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Oscar Esgalha
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Laranja
|
2
|
+
[](https://travis-ci.org/oesgalha/laranja)
|
3
|
+
|
4
|
+
Laranja is a ruby gem which generates random fake valid data.
|
5
|
+
It aims to help testing brazilian applications, since it generates specific data from the country.
|
6
|
+
You can use it in your automated tests or to populate development databases.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'laranja'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install laranja
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Names
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'laranja'
|
28
|
+
|
29
|
+
Laranja::Name.name # Vitória Pereira
|
30
|
+
|
31
|
+
Laranja::Name.name(2) # Ígor Braga Santos => Name with 2 surnames
|
32
|
+
|
33
|
+
Laranja::Name.first_name # Raul
|
34
|
+
|
35
|
+
Laranja::Name.last_name # Moreira
|
36
|
+
|
37
|
+
Laranja::Name.strfname(3, true, true) # Fabrício Santos Costa Reis Junior => Name with 3 surnames, suffix and first name
|
38
|
+
|
39
|
+
Laranja::Name.strfname(1, true, false) # Albuquerque Neto => Name with 1 surname, suffix but without first name
|
40
|
+
```
|
41
|
+
|
42
|
+
### CPF
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'laranja'
|
46
|
+
|
47
|
+
Laranja::CPF # 23379020648
|
48
|
+
|
49
|
+
Laranja::CPF.formatted # 524.966.867-49
|
50
|
+
|
51
|
+
Laranja::CPF.cpf(:rj) # 29564858739 => Random CPF from Rio de Janeiro
|
52
|
+
|
53
|
+
Laranja::CPF.formatted(:BA) # 101.182.995-90 => Random CPF from Bahia
|
54
|
+
|
55
|
+
Laranja::CPF.cpf('RS') # 73272882014 => Random CPF from Rio Grande do Sul
|
56
|
+
|
57
|
+
Laranja::CPF.cpf('sp') # 07537191859 => Random CPF from São Paulo
|
58
|
+
```
|
59
|
+
|
60
|
+
### Internet
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
require 'laranja'
|
64
|
+
|
65
|
+
Laranja::Internet.email # elsionogueira@gmail.com
|
66
|
+
|
67
|
+
Laranja::Internet.strfemail('Vitória Pereira') # vitria.pereira@yahoo.com
|
68
|
+
|
69
|
+
Laranja::Internet.username # marli.macedo
|
70
|
+
|
71
|
+
Laranja::Internet.strfusername('Ana Machado') # anamachado
|
72
|
+
|
73
|
+
Laranja::Internet.strfusername('Joel Melo', ['-']) # joel-melo => Username with one of the specified separators ( - )
|
74
|
+
|
75
|
+
Laranja::Internet.password # Pq9vD8VJzttr6vrB77hDCp2LVK8iSm1iUjezQuS9dlah0EUukfQDPLf5ad0e6WwsrI39
|
76
|
+
|
77
|
+
Laranja::Internet.password(2, 6) # COW => Password with a random number of charaters between 2 and 6 (the default is 8 and 128)
|
78
|
+
```
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/laranja.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'laranja/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'laranja'
|
8
|
+
spec.version = Laranja::VERSION
|
9
|
+
spec.authors = ['Oscar Esgalha']
|
10
|
+
spec.email = ['oscaresgalha@gmail.com\n']
|
11
|
+
spec.description = %q{Grab some valid brazilian fake data. For testing.}
|
12
|
+
spec.summary = %q{Laranja will generate valid brazilian fake data, which can be used for automated testing or populating development databases.}
|
13
|
+
spec.homepage = 'https://github.com/oesgalha/laranja'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'safe_yaml'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
data/lib/laranja.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'safe_yaml'
|
2
|
+
SafeYAML::OPTIONS[:default_mode] = :safe
|
3
|
+
|
4
|
+
module Laranja
|
5
|
+
class Base
|
6
|
+
|
7
|
+
def self.specified(format)
|
8
|
+
format.gsub(/%([^%\s\z]+)/) { data_sample($1) }
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def self.data_sample(key)
|
14
|
+
data(key).sample
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.data(key)
|
18
|
+
static_data[to_s.split('::')[-1].downcase][key]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.static_data
|
24
|
+
@static_data ||= YAML.load_file(File.join(File.expand_path(File.dirname(__FILE__)), 'static_data.yml'))['laranja']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'laranja/cpf'
|
30
|
+
require 'laranja/internet'
|
31
|
+
require 'laranja/name'
|
data/lib/laranja/cpf.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Laranja
|
2
|
+
class CPF < Base
|
3
|
+
|
4
|
+
def self.cpf(uf = nil)
|
5
|
+
cpf = '########U'.sub(/U/, uf.nil? ? '#' : uf_code(uf)).gsub(/#/) { rand(10).to_s }
|
6
|
+
v = [(0..8).inject(0) { |sum, i| sum + cpf[i].to_i * (10 - i) } % 11]
|
7
|
+
v[0] = v[0] < 2 ? 0 : 11 - v[0]
|
8
|
+
v[1] = ((0..8).inject(0) { |sum, i| sum + cpf[i].to_i * (11 - i) } + v[0] * 2) % 11
|
9
|
+
v[1] = v[1] < 2 ? 0 : 11 - v[1]
|
10
|
+
cpf += v.join
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.formatted(uf = nil)
|
14
|
+
c = cpf(uf)
|
15
|
+
'%03d.%03d.%03d-%02d' % [ c[0..2].to_i, c[3..5].to_i, c[6..8].to_i, c[9..10].to_i ]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.uf_code(uf)
|
21
|
+
data('codigo_uf')[uf.to_s.downcase].to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Laranja
|
2
|
+
class Internet < Base
|
3
|
+
|
4
|
+
def self.strfemail(name)
|
5
|
+
specified strfusername(name) + '@%email'
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.email
|
9
|
+
strfemail(Laranja::Name.name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.strfusername(name, sep = ['', '.', '_'])
|
13
|
+
name.gsub(/[^a-zA-Z0-9\s]/, '').split.join(sep.sample).downcase
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.username
|
17
|
+
strfusername(Laranja::Name.name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.password(min = 8, max = 128)
|
21
|
+
characters = ('0'.upto('9').to_a + 'A'.upto('Z').to_a + 'a'.upto('z').to_a)
|
22
|
+
size = min + rand(max - min)
|
23
|
+
(1..size).inject('') { |passcode, i| passcode + characters.sample }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/laranja/name.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Laranja
|
2
|
+
class Name < Base
|
3
|
+
|
4
|
+
def self.strfname(last_names = 1, suffix = false, first_name = true)
|
5
|
+
f = ''
|
6
|
+
f += '%first_name' if first_name
|
7
|
+
f += ' %last_name' * last_names
|
8
|
+
f += ' %suffix' if suffix
|
9
|
+
specified f.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.name(last_names = 1)
|
13
|
+
strfname last_names, rand(9) == 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.first_name
|
17
|
+
strfname 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.last_name
|
21
|
+
strfname 1, false, false
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/static_data.yml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
laranja:
|
2
|
+
internet:
|
3
|
+
email: ['bol.com.br', 'gmail.com', 'hotmail.com', 'live.com', 'terra.com.br', 'uol.com.br', 'yahoo.com']
|
4
|
+
name:
|
5
|
+
first_name: ['Alessandro', 'Alessandra', 'Alexandre', 'Aline', 'Antônio', 'Breno', 'Bruna', 'Carlos', 'Carla', 'Célia', 'Cecília', 'César', 'Danilo', 'Dalila', 'Deneval', 'Eduardo', 'Eduarda', 'Esther', 'Elísio', 'Fábio', 'Fabrício', 'Fabrícia', 'Félix', 'Felícia', 'Feliciano', 'Frederico', 'Fabiano', 'Gustavo', 'Guilherme', 'Gúbio', 'Heitor', 'Hélio', 'Hugo', 'Isabel', 'Isabela', 'Ígor', 'João', 'Joana', 'Júlio César', 'Júlio', 'Júlia', 'Janaína', 'Karla', 'Kléber', 'Lucas', 'Lorena', 'Lorraine', 'Larissa', 'Ladislau', 'Marcos', 'Meire', 'Marcelo', 'Marcela', 'Margarida', 'Mércia', 'Márcia', 'Marli', 'Morgana', 'Maria', 'Norberto', 'Natália', 'Nataniel', 'Núbia', 'Ofélia', 'Paulo', 'Paula', 'Pablo', 'Pedro', 'Raul', 'Rafael', 'Rafaela', 'Ricardo', 'Roberto', 'Roberta', 'Sílvia', 'Sílvia', 'Silas', 'Suélen', 'Sara', 'Salvador', 'Sirineu', 'Talita', 'Tertuliano', 'Vicente', 'Víctor', 'Vitória', 'Yango', 'Yago', 'Yuri', 'Washington', 'Warley']
|
6
|
+
last_name: ['Albuquerque', 'Barros', 'Batista', 'Braga', 'Costa', 'Carvalho', 'Franco', 'Macedo', 'Martins', 'Melo', 'Moraes', 'Moreira', 'Nogueira', 'Oliveira', 'Pereira', 'Reis', 'Santos', 'Saraiva', 'Silva', 'Souza', 'Xavier']
|
7
|
+
suffix: ['Junior', 'Neto', 'Filho']
|
8
|
+
cpf:
|
9
|
+
codigo_uf: { ac: 2, al: 4, ap: 2, am: 2, ba: 5, ce: 3, df: 1, es: 7, go: 1, ma: 3, mt: 1, ms: 1, mg: 6, pa: 2, pb: 4, pr: 9, pe: 4, pi: 3, rj: 7, rn: 4, rs: 0, ro: 2, rr: 2, sc: 9, sp: 8, se: 5, to: 1 }
|
data/spec/cpf_spec.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'a cpf generator' do |cpf|
|
4
|
+
describe 'and' do
|
5
|
+
it 'return a string' do
|
6
|
+
expect(cpf).to be_a_kind_of(String)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'return a string with 11 characters' do
|
10
|
+
expect(cpf.size).to eq(11)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'return a valid cpf' do
|
14
|
+
v1, v2 = 0, 0
|
15
|
+
for i in 0..8
|
16
|
+
v1 += cpf[i].to_i * (10 - i)
|
17
|
+
v2 += cpf[i].to_i * (11 - i)
|
18
|
+
end
|
19
|
+
v1 = v1 % 11
|
20
|
+
if v1 < 2
|
21
|
+
v1 = 0
|
22
|
+
else
|
23
|
+
v1 = 11 - v1
|
24
|
+
end
|
25
|
+
v2 += v1 * 2
|
26
|
+
v2 = v2 % 11
|
27
|
+
if v2 < 2
|
28
|
+
v2 = 0
|
29
|
+
else
|
30
|
+
v2 = 11 - v2
|
31
|
+
end
|
32
|
+
expect(cpf[-2].to_i).to eq(v1)
|
33
|
+
expect(cpf[-1].to_i).to eq(v2)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Laranja::CPF do
|
39
|
+
describe '#cpf' do
|
40
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf
|
41
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf(:ce)
|
42
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf(:BA)
|
43
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf('rj')
|
44
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf('RS')
|
45
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.cpf(:sp)
|
46
|
+
|
47
|
+
it 'has the UF digit if an UF is specified' do
|
48
|
+
expect(Laranja::CPF.cpf(:ce)[-3].to_i).to eq(3)
|
49
|
+
expect(Laranja::CPF.cpf(:BA)[-3].to_i).to eq(5)
|
50
|
+
expect(Laranja::CPF.cpf('rj')[-3].to_i).to eq(7)
|
51
|
+
expect(Laranja::CPF.cpf('RS')[-3].to_i).to eq(0)
|
52
|
+
expect(Laranja::CPF.cpf(:sp)[-3].to_i).to eq(8)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#formatted' do
|
57
|
+
it_behaves_like 'a cpf generator', Laranja::CPF.formatted.gsub(/\D+/, '')
|
58
|
+
it 'return a formatted cpf string' do
|
59
|
+
expect(Laranja::CPF.formatted).to match(/\d{3}\.\d{3}\.\d{3}-\d{2}/)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Laranja::Internet do
|
4
|
+
describe '#email' do
|
5
|
+
it 'returns a string' do
|
6
|
+
expect(Laranja::Internet.email).to be_a_kind_of(String)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns a valid email' do
|
10
|
+
expect(Laranja::Internet.email).to match(/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#strfemail' do
|
15
|
+
|
16
|
+
let (:name) { 'John Doe' }
|
17
|
+
|
18
|
+
it 'returns a string' do
|
19
|
+
expect(Laranja::Internet.strfemail(name)).to be_a_kind_of(String)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns a valid email' do
|
23
|
+
expect(Laranja::Internet.strfemail(name)).to match(/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns an email for the given name' do
|
27
|
+
expect(Laranja::Internet.strfemail(name)).to include('john')
|
28
|
+
expect(Laranja::Internet.strfemail(name)).to include('doe')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#username' do
|
33
|
+
it 'returns a string' do
|
34
|
+
expect(Laranja::Internet.username).to be_a_kind_of(String)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns a non empty string' do
|
38
|
+
expect(Laranja::Internet.username).not_to be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#strfusername' do
|
43
|
+
|
44
|
+
let (:name) { 'John Doe' }
|
45
|
+
|
46
|
+
it 'returns a string' do
|
47
|
+
expect(Laranja::Internet.strfusername(name)).to be_a_kind_of(String)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'returns an username for the given name' do
|
51
|
+
expect(Laranja::Internet.strfusername(name)).to include('john')
|
52
|
+
expect(Laranja::Internet.strfusername(name)).to include('doe')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns an username for the given name and separator' do
|
56
|
+
expect(Laranja::Internet.strfusername(name, ['-'])).to eq('john-doe')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#password' do
|
61
|
+
it 'returns a string' do
|
62
|
+
expect(Laranja::Internet.password).to be_a_kind_of(String)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns an alphanumeric string' do
|
66
|
+
expect(Laranja::Internet.password).not_to match(/\W/)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns a password with minimum length' do
|
70
|
+
expect(Laranja::Internet.password(32).size).to be >= 32
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns a password with minimum and maximum length' do
|
74
|
+
expect(Laranja::Internet.password(64, 64).size).to eq(64)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/name_spec.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'a name generator' do |name|
|
4
|
+
describe 'and' do
|
5
|
+
it 'returns a string' do
|
6
|
+
expect(name).to be_a_kind_of(String)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns a string with only one word' do
|
10
|
+
expect(name.split.size).to eq(1)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Laranja::Name do
|
16
|
+
describe '#name' do
|
17
|
+
|
18
|
+
let(:n) { 1 + rand(3) }
|
19
|
+
|
20
|
+
it 'returns a string' do
|
21
|
+
expect(Laranja::Name.name).to be_a_kind_of(String)
|
22
|
+
expect(Laranja::Name.name(2)).to be_a_kind_of(String)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a first name and a last name' do
|
26
|
+
expect(Laranja::Name.name.split.size).to be_between(2, 3)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns N last names when specified' do
|
30
|
+
expect(Laranja::Name.name(n).split.size).to be_between(n + 1, n + 2)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#first_name' do
|
35
|
+
it_behaves_like 'a name generator', Laranja::Name.first_name
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#last_name' do
|
39
|
+
it_behaves_like 'a name generator', Laranja::Name.last_name
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#strfname' do
|
43
|
+
|
44
|
+
let(:n) { 1 + rand(3) }
|
45
|
+
|
46
|
+
it_behaves_like 'a name generator', Laranja::Name.strfname(0)
|
47
|
+
it_behaves_like 'a name generator', Laranja::Name.strfname(1, false, false)
|
48
|
+
it_behaves_like 'a name generator', Laranja::Name.strfname(0, true, false)
|
49
|
+
|
50
|
+
it 'returns N last names when specified' do
|
51
|
+
expect(Laranja::Name.strfname(n).split.size).to eq(n + 1)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns N last names plus suffix when specified' do
|
55
|
+
expect(Laranja::Name.strfname(n, true).split.size).to eq(n + 2)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: laranja
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Oscar Esgalha
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: safe_yaml
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Grab some valid brazilian fake data. For testing.
|
79
|
+
email:
|
80
|
+
- oscaresgalha@gmail.com\n
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- .rspec
|
87
|
+
- .travis.yml
|
88
|
+
- Gemfile
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- laranja.gemspec
|
93
|
+
- lib/laranja.rb
|
94
|
+
- lib/laranja/cpf.rb
|
95
|
+
- lib/laranja/internet.rb
|
96
|
+
- lib/laranja/name.rb
|
97
|
+
- lib/laranja/version.rb
|
98
|
+
- lib/static_data.yml
|
99
|
+
- spec/cpf_spec.rb
|
100
|
+
- spec/internet_spec.rb
|
101
|
+
- spec/name_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/oesgalha/laranja
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
hash: -4502812516592306042
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: -4502812516592306042
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.8.25
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: Laranja will generate valid brazilian fake data, which can be used for automated
|
134
|
+
testing or populating development databases.
|
135
|
+
test_files:
|
136
|
+
- spec/cpf_spec.rb
|
137
|
+
- spec/internet_spec.rb
|
138
|
+
- spec/name_spec.rb
|
139
|
+
- spec/spec_helper.rb
|