identificamex 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +47 -5
- data/Rakefile +1 -1
- data/lib/identificamex.rb +26 -1
- data/lib/identificamex/nombre/mayusculas.rb +35 -0
- data/lib/identificamex/nombre/nombre_completo.rb +96 -0
- data/lib/identificamex/nombre/normalizador_apellido.rb +30 -0
- data/lib/identificamex/nombre/normalizador_cadena.rb +47 -0
- data/lib/identificamex/nombre/normalizador_nombre.rb +42 -0
- data/lib/identificamex/nombre/palabra_inconveniente.rb +55 -0
- data/lib/identificamex/nombre/razon_social.rb +92 -0
- data/lib/identificamex/rfc/homoclave.rb +209 -0
- data/lib/identificamex/rfc/rfc_base.rb +32 -0
- data/lib/identificamex/rfc/rfc_generator.rb +95 -0
- data/lib/identificamex/version.rb +1 -1
- data/lib/rfc_format_validator.rb +2 -2
- data/test/identificamex/methods_validator_test.rb +35 -0
- data/test/identificamex/nombre/nombre_completo_test.rb +64 -0
- data/test/identificamex/nombre/normalizador_apellido_test.rb +30 -0
- data/test/identificamex/nombre/normalizador_nombre_test.rb +62 -0
- data/test/identificamex/nombre/razon_social_test.rb +68 -0
- data/test/identificamex/rfc/homoclave_test.rb +24 -0
- data/test/identificamex/rfc/rfc_base_test.rb +24 -0
- data/test/identificamex/rfc/rfc_generator_test.rb +170 -0
- data/test/identificamex/rfc_format_validator_test.rb +4 -4
- data/test/test_helper.rb +7 -1
- metadata +30 -3
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class Dummy
|
4
|
+
include Identificamex::Methods
|
5
|
+
end
|
6
|
+
|
7
|
+
describe 'test helper' do
|
8
|
+
it 'returns true when the RFC is valid for persona moral' do
|
9
|
+
params = { razon_social: 'Sonora Industrial Azucarera, S. de R.L',
|
10
|
+
fecha_creacion: Date.new(1983, 03, 05) }
|
11
|
+
assert Dummy.new.valid_rfc?('SIA8303054L5', params)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns true when the RFC is valid for persona fisica' do
|
15
|
+
params = { nombre: 'Juan',
|
16
|
+
primer_apellido: 'Barrios',
|
17
|
+
segundo_apellido: 'Fernández',
|
18
|
+
fecha_nacimiento: Date.new(1970, 12, 13) }
|
19
|
+
assert Dummy.new.valid_rfc?('BAFJ701213SBA', params)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns false when the RFC is invalid for persona moral' do
|
23
|
+
params = { razon_social: 'Sonora Industrial Azucarera Moderna, S. de R.L',
|
24
|
+
fecha_creacion: Date.new(1983, 03, 05) }
|
25
|
+
assert !Dummy.new.valid_rfc?('SIA8303054L5', params)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns false when the RFC is valid for persona física' do
|
29
|
+
params = { nombre: 'Juan José',
|
30
|
+
primer_apellido: 'Barrios',
|
31
|
+
segundo_apellido: 'Fernández',
|
32
|
+
fecha_nacimiento: Date.new(1970, 12, 13) }
|
33
|
+
assert !Dummy.new.valid_rfc?('BAFJ701213SBA', params)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/nombre/nombre_completo'
|
3
|
+
|
4
|
+
module Identificamex
|
5
|
+
module Nombre
|
6
|
+
describe NombreCompleto do
|
7
|
+
|
8
|
+
describe '#to_s' do
|
9
|
+
it 'is (primer apellido segundo apellido y nombre) with no special characters' do
|
10
|
+
params = {nombre: 'José Alfredo', primer_apellido: "D'Angelo", segundo_apellido: 'López'}
|
11
|
+
nombre_completo = NombreCompleto.new(params).to_s.must_equal 'DANGELO LOPEZ JOSE ALFREDO'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#siglas' do
|
16
|
+
context 'usual cases' do
|
17
|
+
it 'takes 2 letters from primero_apellido, 1 from segundo_apellido and 1 from the nombre' do
|
18
|
+
params = {primer_apellido: 'Lopez', segundo_apellido: 'Sanchez', nombre: 'Ramiro'}
|
19
|
+
NombreCompleto.new(params).siglas.must_equal 'LOSR'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'takes 2 letters from primero_apellido, 1 from segundo_apellido and 1 from the nombre' do
|
23
|
+
params = {primer_apellido: 'Antonio', segundo_apellido: 'Sanchez', nombre: 'Ramiro'}
|
24
|
+
NombreCompleto.new(params).siglas.must_equal 'AOSR'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'special cases' do
|
29
|
+
context 'nombre, primer_apellido and segundo_apellido have invalid words' do
|
30
|
+
it 'takes the letters ignoring invalid words' do
|
31
|
+
params = {primer_apellido: 'Del Angel', segundo_apellido: 'De la Rosa', nombre: 'Jose Ramiro'}
|
32
|
+
NombreCompleto.new(params).siglas.must_equal 'AERR'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when primer_apellido has just one letter' do
|
37
|
+
it 'takes 1 letter from primer_apellido, 1 from sengudo_apellido and 2 from nombre' do
|
38
|
+
params = {primer_apellido: 'DE LA O', segundo_apellido: 'SANCHEZ', nombre: 'RAMIRO'}
|
39
|
+
NombreCompleto.new(params).siglas.must_equal 'OSRA'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when primer_apellido is nil' do
|
44
|
+
it 'takes 2 letters from segundo_apellido and 2 letters from nombre' do
|
45
|
+
params = {primer_apellido: nil, segundo_apellido: 'SANCHEZ', nombre: 'RAMIRO'}
|
46
|
+
NombreCompleto.new(params).siglas.must_equal 'SARA'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when segundo_apellido is nil' do
|
51
|
+
it 'takes 2 letters from primer_apellido and 2 letters from nombre' do
|
52
|
+
params = {primer_apellido: 'Sanchez', segundo_apellido: nil, nombre: 'RAMIRO'}
|
53
|
+
NombreCompleto.new(params).siglas.must_equal 'SARA'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end # context especial cases
|
58
|
+
|
59
|
+
|
60
|
+
end #describe #siglas
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/nombre/normalizador_apellido'
|
3
|
+
|
4
|
+
module Identificamex
|
5
|
+
module Nombre
|
6
|
+
|
7
|
+
describe NormalizadorApellido do
|
8
|
+
it 'keeps (SANCHEZ)' do
|
9
|
+
NormalizadorNombre.new('Sánchez').normalizar.must_equal 'SANCHEZ'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'removes DE LA' do
|
13
|
+
NormalizadorNombre.new('De la Rosa').normalizar.must_equal 'ROSA'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'removes DEL' do
|
17
|
+
NormalizadorNombre.new('Del Toro').normalizar.must_equal 'TORO'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'removes DE LOS' do
|
21
|
+
NormalizadorNombre.new('De los Santos').normalizar.must_equal 'SANTOS'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes LA' do
|
25
|
+
NormalizadorNombre.new('La Torre').normalizar.must_equal 'TORRE'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/nombre/normalizador_nombre'
|
3
|
+
|
4
|
+
module Identificamex
|
5
|
+
module Nombre
|
6
|
+
|
7
|
+
describe NormalizadorNombre do
|
8
|
+
it 'keeps (MARTHA)' do
|
9
|
+
NormalizadorNombre.new('Martha').normalizar.must_equal 'MARTHA'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'removes MARIA' do
|
13
|
+
NormalizadorNombre.new('María Fernanda').normalizar.must_equal 'FERNANDA'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'removes MARIA DEL' do
|
17
|
+
NormalizadorNombre.new('María del Carmen').normalizar.must_equal 'CARMEN'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'removes MARIA DE' do
|
21
|
+
NormalizadorNombre.new('María de Lourdes').normalizar.must_equal 'LOURDES'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes MARIA DE LOS' do
|
25
|
+
NormalizadorNombre.new('María de los Ángeles').normalizar.must_equal 'ANGELES'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'removes MARIA DE LA' do
|
29
|
+
NormalizadorNombre.new('María de la Trinidad').normalizar.must_equal 'TRINIDAD'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'keeps MARIA' do
|
33
|
+
NormalizadorNombre.new('María').normalizar.must_equal 'MARIA'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'keeps MARIA' do
|
37
|
+
NormalizadorNombre.new('María José').normalizar.must_equal 'MARIA'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'keeps (ANTONIO)' do
|
41
|
+
NormalizadorNombre.new('Antonio').normalizar.must_equal 'ANTONIO'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'removes JOSE' do
|
45
|
+
NormalizadorNombre.new('José Fernando').normalizar.must_equal 'FERNANDO'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'removes JOSE DE' do
|
49
|
+
NormalizadorNombre.new('José de Jesús').normalizar.must_equal 'JESUS'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'keeps JOSE' do
|
53
|
+
NormalizadorNombre.new('José').normalizar.must_equal 'JOSE'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'keeps JOSE' do
|
57
|
+
NormalizadorNombre.new('José María').normalizar.must_equal 'JOSE'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/nombre/razon_social'
|
3
|
+
|
4
|
+
module Identificamex
|
5
|
+
module Nombre
|
6
|
+
|
7
|
+
describe RazonSocial do
|
8
|
+
|
9
|
+
describe '#to_s' do
|
10
|
+
it 'is razon_social (sin siglas de forma jurídica)' do
|
11
|
+
rs = RazonSocial.new('LogicalBricks Solutions S.C. de R.L de CV.')
|
12
|
+
rs.to_s.must_equal 'LOGICALBRICKS SOLUTIONS'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is razon_social (abreviaturas sin puntos)' do
|
16
|
+
rs = RazonSocial.new('A.M. Relojería')
|
17
|
+
rs.to_s.must_equal 'A M RELOJERIA'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#siglas' do
|
22
|
+
context 'when company name has 3 words' do
|
23
|
+
it 'takes the first letters of the 3 words' do
|
24
|
+
RazonSocial.new('Sonora Industrial Azucarera, S. de R.L').siglas.must_equal 'SIA'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'takes the first letters of the 3 words skipping invalid names' do
|
28
|
+
RazonSocial.new('Compañía Sonora Industrial del Azucar, S. de R.L').siglas.must_equal 'SIA'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when company name has 2 words' do
|
33
|
+
it 'takes the first letter from the first word and 2 letters from the second word' do
|
34
|
+
RazonSocial.new('Soc. Sonora Industrial, S. de R.L').siglas.must_equal 'SIN'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when company name has 1 word' do
|
39
|
+
context 'when word has more than 3 letters' do
|
40
|
+
it 'takes the first 3 letters from the first word' do
|
41
|
+
RazonSocial.new('Soc. Sonora, S. de R.L').siglas.must_equal 'SON'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when word has 3 letters' do
|
46
|
+
it 'takes the first 3 letters from the first word' do
|
47
|
+
RazonSocial.new('Sol, S. A.').siglas.must_equal 'SOL'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when word has 2 letters' do
|
52
|
+
it 'takes the first 3 letters from the first word' do
|
53
|
+
RazonSocial.new('Pi, S.A.').siglas.must_equal 'PIX'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when word has 1 letter' do
|
58
|
+
it 'takes the first 3 letters from the first word' do
|
59
|
+
RazonSocial.new('Z, SA').siglas.must_equal 'ZXX'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/rfc/homoclave'
|
3
|
+
|
4
|
+
module Identificamex
|
5
|
+
module Rfc
|
6
|
+
|
7
|
+
describe Homoclave do
|
8
|
+
context 'persona física' do
|
9
|
+
it 'builds homoclave' do
|
10
|
+
rfc_base = OpenStruct.new(nombre_completo: 'GOMEZ DIAZ EMMA', siglas: 'GODE561231') # kind of stub
|
11
|
+
assert_equal 'GR8', Homoclave.new(rfc_base).siglas
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'persona moral' do
|
16
|
+
it 'builds homoclave' do
|
17
|
+
rfc_base = OpenStruct.new(nombre_completo: 'LOGICALBRICKS SOLUTIONS', siglas: 'LSO110121') # kind of stub
|
18
|
+
assert_equal 'SY0', Homoclave.new(rfc_base).siglas
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/rfc/rfc_base'
|
3
|
+
require_relative '../../../lib/identificamex/nombre/nombre_completo'
|
4
|
+
|
5
|
+
module Identificamex
|
6
|
+
module Rfc
|
7
|
+
|
8
|
+
describe RfcBase do
|
9
|
+
context 'persona física' do
|
10
|
+
it 'builds rfc base' do
|
11
|
+
nombre = ::Identificamex::Nombre::NombreCompleto.new(
|
12
|
+
nombre: 'Emma',
|
13
|
+
primer_apellido: 'Gómez',
|
14
|
+
segundo_apellido: 'Díaz'
|
15
|
+
)
|
16
|
+
fecha = Date.new(1956, 12, 31)
|
17
|
+
rfc_base = RfcBase.new(nombre: nombre, fecha_nacimiento: fecha)
|
18
|
+
assert_equal 'GODE561231', rfc_base.siglas
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../../lib/identificamex/rfc/rfc_generator'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module Identificamex
|
6
|
+
module Rfc
|
7
|
+
|
8
|
+
describe RfcGenerator do
|
9
|
+
describe 'persona física' do
|
10
|
+
it 'nombre, primer apellido inicia con consonante, segundo apellido y fecha de nacimiento' do
|
11
|
+
generator = RfcGenerator.new(nombre: 'Juan',
|
12
|
+
primer_apellido: 'Barrios',
|
13
|
+
segundo_apellido: 'Fernández',
|
14
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
15
|
+
generator.rfc.must_equal 'BAFJ701213SBA'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'nombre, primer apellido inicia con vocal, segundo apellido y fecha de nacimiento' do
|
19
|
+
generator = RfcGenerator.new(nombre: 'Juan',
|
20
|
+
primer_apellido: 'Antonio',
|
21
|
+
segundo_apellido: 'Fernández',
|
22
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
23
|
+
generator.rfc.must_equal 'AOFJ701213LN8'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'nombre, primer apellido inicia con letra compuesta, segundo apellido y fecha de nacimiento' do
|
27
|
+
generator = RfcGenerator.new(nombre: 'Charles',
|
28
|
+
primer_apellido: 'Chávez',
|
29
|
+
segundo_apellido: 'Llamas',
|
30
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
31
|
+
generator.rfc.must_equal 'CALC701213R55'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'nombre, primer apellido sin vocal interna, segundo apellido y fecha de nacimiento' do
|
35
|
+
generator = RfcGenerator.new(nombre: 'Álvaro',
|
36
|
+
primer_apellido: 'de la O',
|
37
|
+
segundo_apellido: 'Lozano',
|
38
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
39
|
+
generator.rfc.must_equal 'OLAL701213R92'
|
40
|
+
|
41
|
+
generator = RfcGenerator.new(nombre: 'Ernesto',
|
42
|
+
primer_apellido: 'Ek',
|
43
|
+
segundo_apellido: 'Rivera',
|
44
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
45
|
+
generator.rfc.must_equal 'ERER7012139E5'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'nombre, sin primer apellido, segundo apellido y fecha de nacimiento' do
|
49
|
+
generator = RfcGenerator.new(nombre: 'Gerarda',
|
50
|
+
primer_apellido: nil,
|
51
|
+
segundo_apellido: 'Zafra',
|
52
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
53
|
+
generator.rfc.must_equal 'ZAGE701213920'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'nombre, primer apellido, sin segundo apellido, fecha de nacimiento' do
|
57
|
+
generator = RfcGenerator.new(nombre: 'Juan',
|
58
|
+
primer_apellido: 'Martínez',
|
59
|
+
segundo_apellido: nil,
|
60
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
61
|
+
generator.rfc.must_equal 'MAJU701213BP2'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'Nombre, primer apellido con caracter especial, segundo apellido y fecha de nacimiento' do
|
65
|
+
generator = RfcGenerator.new(nombre: 'Roberto',
|
66
|
+
primer_apellido: "O'farril",
|
67
|
+
segundo_apellido: 'Carballo',
|
68
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
69
|
+
generator.rfc.must_equal 'OACR701213B44'
|
70
|
+
|
71
|
+
generator = RfcGenerator.new(nombre: 'Rubén',
|
72
|
+
primer_apellido: "D'angelo",
|
73
|
+
segundo_apellido: 'Fargo',
|
74
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
75
|
+
generator.rfc.must_equal 'DAFR701213127'
|
76
|
+
|
77
|
+
generator = RfcGenerator.new(nombre: 'Luz Ma.',
|
78
|
+
primer_apellido: 'Fernández',
|
79
|
+
segundo_apellido: 'Juárez',
|
80
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
81
|
+
generator.rfc.must_equal 'FEJL701213158'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'palabra inapropiada' do
|
85
|
+
generator = RfcGenerator.new(nombre: 'Omar',
|
86
|
+
primer_apellido: 'Pérez',
|
87
|
+
segundo_apellido: 'Domínguez',
|
88
|
+
fecha_nacimiento: Date.new(1970, 12, 13))
|
89
|
+
generator.rfc.must_equal 'PEDX7012139FA'
|
90
|
+
end
|
91
|
+
end #Describe persona física
|
92
|
+
|
93
|
+
describe 'Persona moral' do
|
94
|
+
it 'takes the first letter of three words' do
|
95
|
+
generator = RfcGenerator.new(razon_social: 'Sonora Industrial Azucarera, S. de R.L',
|
96
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
97
|
+
generator.rfc.must_equal 'SIA8303054L5'
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'takes the first letter of three words skipping invalid words' do
|
101
|
+
generator = RfcGenerator.new(razon_social: 'Artículos de piel y Baúles, S. de R. L.',
|
102
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
103
|
+
generator.rfc.must_equal 'APB830305QS6'
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'ignores the second letter of the compound letters' do
|
107
|
+
generator = RfcGenerator.new(razon_social: 'Champion Mexicana de Bujías, S.A.',
|
108
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
109
|
+
generator.rfc.must_equal 'CMB830305L62'
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'ignores the dot and takes single letters' do
|
113
|
+
generator = RfcGenerator.new(razon_social: 'U.S. Ruber Mexicana, S.A.',
|
114
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
115
|
+
generator.rfc.must_equal 'USR830305L44'
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'takes the first letter from first word and two letters from second word' do
|
119
|
+
generator = RfcGenerator.new(razon_social: 'Aceros Ecatepec, S.A.',
|
120
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
121
|
+
generator.rfc.must_equal 'AEC83030546A'
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'takes the three letters from first word' do
|
125
|
+
generator = RfcGenerator.new(razon_social: 'Arsuyama, S.A.',
|
126
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
127
|
+
generator.rfc.must_equal 'ARS830305GYA'
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'adds xx when the company name has one letter' do
|
131
|
+
generator = RfcGenerator.new(razon_social: 'Z, S.A.',
|
132
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
133
|
+
generator.rfc.must_equal 'ZXX830305BLA'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'ignores invalid words (los, de)' do
|
137
|
+
generator = RfcGenerator.new(razon_social: 'Los Viajes Internacionales de Marco Polo, S.A.',
|
138
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
139
|
+
generator.rfc.must_equal 'VIM8303056B6'
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'ignores invalid words (y, para)' do
|
143
|
+
generator = RfcGenerator.new(razon_social: 'Artículos y Accesorios para Automóviles, S.A.',
|
144
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
145
|
+
generator.rfc.must_equal 'AAA830305184'
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'ignores invalid words (el)' do
|
149
|
+
generator = RfcGenerator.new(razon_social: 'El abastecedor Ferretero, S.A.',
|
150
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
151
|
+
generator.rfc.must_equal 'AFE830305STA'
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'ignores (compañia)' do
|
155
|
+
generator = RfcGenerator.new(razon_social: 'Compañía Periodística Nacional, S.A.',
|
156
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
157
|
+
generator.rfc.must_equal 'PNA830305LT5'
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'ignores (cia.)' do
|
161
|
+
generator = RfcGenerator.new(razon_social: 'Pimienta Hnos. y Cía., S.A.',
|
162
|
+
fecha_creacion: Date.new(1983, 03, 05))
|
163
|
+
generator.rfc.must_equal 'PHN830305RY9'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|