rnfse 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +14 -0
  5. data/CHANGELOG.md +0 -0
  6. data/Gemfile +3 -0
  7. data/Guardfile +15 -0
  8. data/LICENSE.md +41 -0
  9. data/Procfile +1 -0
  10. data/README.md +59 -0
  11. data/Rakefile +12 -0
  12. data/lib/provedores.yml +11 -0
  13. data/lib/rnfse/api/abrasf_1_0/definitions.json +374 -0
  14. data/lib/rnfse/api/abrasf_1_0/recepcionar_lote_rps.json +46 -0
  15. data/lib/rnfse/api/abrasf_1_0.rb +55 -0
  16. data/lib/rnfse/api/iss_net_1_0.rb +6 -0
  17. data/lib/rnfse/api.rb +101 -0
  18. data/lib/rnfse/configuration.rb +18 -0
  19. data/lib/rnfse/core.rb +9 -0
  20. data/lib/rnfse/hash.rb +148 -0
  21. data/lib/rnfse/string.rb +36 -0
  22. data/lib/rnfse/version.rb +3 -0
  23. data/lib/rnfse/xml_builder/abrasf_1_0.rb +95 -0
  24. data/lib/rnfse/xml_builder/iss_net_1_0.rb +70 -0
  25. data/lib/rnfse/xml_builder.rb +10 -0
  26. data/lib/rnfse.rb +22 -0
  27. data/rnfse.gemspec +60 -0
  28. data/spec/api/abrasf_1_0/recepcionar_lote_rps_json_spec.rb +123 -0
  29. data/spec/api/abrasf_1_0_spec.rb +26 -0
  30. data/spec/api/iss_net_1_0_spec.rb +99 -0
  31. data/spec/api_spec.rb +65 -0
  32. data/spec/core_spec.rb +35 -0
  33. data/spec/fixtures/abrasf_1_0/enviar_lote_rps_envio.xml +47 -0
  34. data/spec/fixtures/abrasf_1_0/nfse.xsd +771 -0
  35. data/spec/fixtures/certificate.pem +18 -0
  36. data/spec/fixtures/iss_net_1_0/enviar_lote_rps_envio.xml +75 -0
  37. data/spec/fixtures/key.pem +15 -0
  38. data/spec/fixtures/vcr_cassettes/iss_net_1_0_recepcionar_lote_rps.yml +214 -0
  39. data/spec/hash_spec.rb +205 -0
  40. data/spec/spec_helper.rb +29 -0
  41. data/spec/string_spec.rb +38 -0
  42. data/spec/support/.keep +0 -0
  43. data/spec/version_spec.rb +5 -0
  44. data/spec/xml_builder/abrasf_1_0_spec.rb +63 -0
  45. data/spec/xml_builder/iss_net_1_0_spec.rb +86 -0
  46. data/spec/xml_builder_spec.rb +14 -0
  47. metadata +433 -0
@@ -0,0 +1,18 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIC5jCCAk+gAwIBAgIJAMzd2iNeztRSMA0GCSqGSIb3DQEBCwUAMIGKMQswCQYD
3
+ VQQGEwJCUjEZMBcGA1UECAwQRGlzdHJpdG8gRmVkZXJhbDERMA8GA1UEBwwIQnJh
4
+ c2lsaWExDjAMBgNVBAoMBVJuZnNlMRkwFwYDVQQDDBBybmZzZS5naXRodWIuY29t
5
+ MSIwIAYJKoZIhvcNAQkBFhNhaXRoZXJpb3NAZ21haWwuY29tMCAXDTE0MDcxMDEx
6
+ MTMyOFoYDzIxMTQwNjE2MTExMzI4WjCBijELMAkGA1UEBhMCQlIxGTAXBgNVBAgM
7
+ EERpc3RyaXRvIEZlZGVyYWwxETAPBgNVBAcMCEJyYXNpbGlhMQ4wDAYDVQQKDAVS
8
+ bmZzZTEZMBcGA1UEAwwQcm5mc2UuZ2l0aHViLmNvbTEiMCAGCSqGSIb3DQEJARYT
9
+ YWl0aGVyaW9zQGdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
10
+ 1cQuK7bqd2w3ZslKWABFQHe3bD43b6SxWbI58ZXwM4VAOHjXJrSe1Ai2Yvd982gW
11
+ Ir9zjQf+CebzW7N/Es7maFQzFP9KlevRldUM8OTThJ6TEVvpLRgeIbgpRQ8bWKB0
12
+ lp3i6AggqCIQT8Q+5HG1bZn+8vjD1ZQ0lCZmyMX85w0CAwEAAaNQME4wHQYDVR0O
13
+ BBYEFGBEjuYDxQcIjemHCelvFmdD85cgMB8GA1UdIwQYMBaAFGBEjuYDxQcIjemH
14
+ CelvFmdD85cgMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEA1QQ8UFQT
15
+ UWRxR8sqmnguN+nQR6GtmDi6XCpgvP73TW68Em/lhdKjzP3RUy3Clw3qv+CV0ebI
16
+ BdHlq5kw12fb2XBVsls+PFnD6yQq9M8fUlUOLe4qz7mAIHw4iBS7I28uvoFsAvqE
17
+ 1ePe8pdP1RFvBMVm5fpduWR0h+z083Ytwkk=
18
+ -----END CERTIFICATE-----
@@ -0,0 +1,75 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <EnviarLoteRpsEnvio
3
+ xmlns="http://www.issnetonline.com.br/webserviceabrasf/vsd/servico_enviar_lote_rps_envio.xsd"
4
+ xmlns:tc="http://www.issnetonline.com.br/webserviceabrasf/vsd/tipos_complexos.xsd">
5
+ <LoteRps>
6
+ <tc:NumeroLote>1</tc:NumeroLote>
7
+ <tc:CpfCnpj>
8
+ <tc:Cnpj>11006269000100</tc:Cnpj>
9
+ </tc:CpfCnpj>
10
+ <tc:InscricaoMunicipal>812005</tc:InscricaoMunicipal>
11
+ <tc:QuantidadeRps>1</tc:QuantidadeRps>
12
+ <tc:ListaRps>
13
+ <tc:Rps>
14
+ <tc:InfRps>
15
+ <tc:IdentificacaoRps>
16
+ <tc:Numero>215</tc:Numero>
17
+ <tc:Serie>10</tc:Serie>
18
+ <tc:Tipo>1</tc:Tipo>
19
+ </tc:IdentificacaoRps>
20
+ <tc:DataEmissao>2009-07-24T10:00:00</tc:DataEmissao>
21
+ <tc:NaturezaOperacao>1</tc:NaturezaOperacao>
22
+ <tc:OptanteSimplesNacional>2</tc:OptanteSimplesNacional>
23
+ <tc:IncentivadorCultural>2</tc:IncentivadorCultural>
24
+ <tc:Status>1</tc:Status>
25
+ <tc:RegimeEspecialTributacao>1</tc:RegimeEspecialTributacao>
26
+ <tc:Servico>
27
+ <tc:Valores>
28
+ <tc:ValorServicos>1100</tc:ValorServicos>
29
+ <tc:ValorPis>10</tc:ValorPis>
30
+ <tc:ValorCofins>20</tc:ValorCofins>
31
+ <tc:ValorInss>30</tc:ValorInss>
32
+ <tc:ValorIr>40</tc:ValorIr>
33
+ <tc:ValorCsll>50</tc:ValorCsll>
34
+ <tc:IssRetido>2</tc:IssRetido>
35
+ <tc:ValorIss>50</tc:ValorIss>
36
+ <tc:BaseCalculo>1000</tc:BaseCalculo>
37
+ <tc:Aliquota>5.00</tc:Aliquota>
38
+ <tc:ValorLiquidoNfse>850</tc:ValorLiquidoNfse>
39
+ <tc:DescontoIncondicionado>0</tc:DescontoIncondicionado>
40
+ <tc:DescontoCondicionado>0</tc:DescontoCondicionado>
41
+ </tc:Valores>
42
+ <tc:ItemListaServico>12</tc:ItemListaServico>
43
+ <tc:CodigoCnae>6311900</tc:CodigoCnae>
44
+ <tc:CodigoTributacaoMunicipio>45217023</tc:CodigoTributacaoMunicipio>
45
+ <tc:Discriminacao>Discriminação da RPS</tc:Discriminacao>
46
+ <tc:MunicipioPrestacaoServico>999</tc:MunicipioPrestacaoServico>
47
+ </tc:Servico>
48
+ <tc:Prestador>
49
+ <tc:CpfCnpj>
50
+ <tc:Cnpj>11006269000100</tc:Cnpj>
51
+ </tc:CpfCnpj>
52
+ <tc:InscricaoMunicipal>812005</tc:InscricaoMunicipal>
53
+ </tc:Prestador>
54
+ <tc:Tomador>
55
+ <tc:IdentificacaoTomador>
56
+ <tc:CpfCnpj>
57
+ <tc:Cnpj>38693524000188</tc:Cnpj>
58
+ </tc:CpfCnpj>
59
+ </tc:IdentificacaoTomador>
60
+ <tc:RazaoSocial>Empresa do Recife</tc:RazaoSocial>
61
+ <tc:Endereco>
62
+ <tc:Endereco>R dos Navegantes 123, 321</tc:Endereco>
63
+ <tc:Numero>123</tc:Numero>
64
+ <tc:Complemento>321</tc:Complemento>
65
+ <tc:Bairro>Boa Viagem</tc:Bairro>
66
+ <tc:Cidade>261160</tc:Cidade>
67
+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rijAFOKNgE
15
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,214 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://www.issnetonline.com.br/webserviceabrasf/homologacao/servicos.asmx
6
+ body:
7
+ encoding: UTF-8
8
+ string: |-
9
+ <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.issnetonline.com.br/webservice/nfd" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><RecepcionarLoteRps><xml><![CDATA[<?xml version="1.0" encoding="utf-8"?>
10
+ <EnviarLoteRpsEnvio xmlns="http://www.issnetonline.com.br/webserviceabrasf/vsd/servico_enviar_lote_rps_envio.xsd" xmlns:tc="http://www.issnetonline.com.br/webserviceabrasf/vsd/tipos_complexos.xsd">
11
+ <LoteRps>
12
+ <tc:NumeroLote>1</tc:NumeroLote>
13
+ <tc:CpfCnpj>
14
+ <tc:Cnpj>14576582000163</tc:Cnpj>
15
+ </tc:CpfCnpj>
16
+ <tc:InscricaoMunicipal>812005</tc:InscricaoMunicipal>
17
+ <tc:QuantidadeRps>1</tc:QuantidadeRps>
18
+ <tc:ListaRps>
19
+ <tc:Rps>
20
+ <tc:InfRps>
21
+ <tc:IdentificacaoRps>
22
+ <tc:Numero>15</tc:Numero>
23
+ <tc:Serie>8</tc:Serie>
24
+ <tc:Tipo>1</tc:Tipo>
25
+ </tc:IdentificacaoRps>
26
+ <tc:DataEmissao>2014-06-24T10:00:00</tc:DataEmissao>
27
+ <tc:NaturezaOperacao>1</tc:NaturezaOperacao>
28
+ <tc:OptanteSimplesNacional>2</tc:OptanteSimplesNacional>
29
+ <tc:IncentivadorCultural>2</tc:IncentivadorCultural>
30
+ <tc:Status>1</tc:Status>
31
+ <tc:RegimeEspecialTributacao>1</tc:RegimeEspecialTributacao>
32
+ <tc:Servico>
33
+ <tc:Valores>
34
+ <tc:ValorServicos>35</tc:ValorServicos>
35
+ <tc:ValorPis>0</tc:ValorPis>
36
+ <tc:ValorCofins>0</tc:ValorCofins>
37
+ <tc:ValorInss>0</tc:ValorInss>
38
+ <tc:ValorIr>0</tc:ValorIr>
39
+ <tc:ValorCsll>0</tc:ValorCsll>
40
+ <tc:IssRetido>2</tc:IssRetido>
41
+ <tc:ValorIss>0</tc:ValorIss>
42
+ <tc:BaseCalculo>35</tc:BaseCalculo>
43
+ <tc:Aliquota>5.00</tc:Aliquota>
44
+ <tc:ValorLiquidoNfse>35</tc:ValorLiquidoNfse>
45
+ <tc:DescontoIncondicionado>0</tc:DescontoIncondicionado>
46
+ <tc:DescontoCondicionado>0</tc:DescontoCondicionado>
47
+ </tc:Valores>
48
+ <tc:ItemListaServico>8</tc:ItemListaServico>
49
+ <tc:CodigoCnae>6399200</tc:CodigoCnae>
50
+ <tc:Discriminacao>Discriminação da RPS</tc:Discriminacao>
51
+ <tc:CodigoTributacaoMunicipio>50000024</tc:CodigoTributacaoMunicipio>
52
+ <tc:MunicipioPrestacaoServico>999</tc:MunicipioPrestacaoServico>
53
+ </tc:Servico>
54
+ <tc:Prestador>
55
+ <tc:CpfCnpj>
56
+ <tc:Cnpj>11006269000100</tc:Cnpj>
57
+ </tc:CpfCnpj>
58
+ <tc:InscricaoMunicipal>124762</tc:InscricaoMunicipal>
59
+ </tc:Prestador>
60
+ <tc:Tomador>
61
+ <tc:IdentificacaoTomador>
62
+ <tc:CpfCnpj>
63
+ <tc:Cpf>93565968834</tc:Cpf>
64
+ </tc:CpfCnpj>
65
+ </tc:IdentificacaoTomador>
66
+ <tc:RazaoSocial>José Serra</tc:RazaoSocial>
67
+ <tc:Endereco>
68
+ <tc:Endereco>R dos Navegantes 123, 321</tc:Endereco>
69
+ <tc:Numero>123</tc:Numero>
70
+ <tc:Complemento>321</tc:Complemento>
71
+ <tc:Bairro>Boa Viagem</tc:Bairro>
72
+ <tc:Cidade>1</tc:Cidade>
73
+ <tc:Estado>PE</tc:Estado>
74
+ <tc:Cep>51021010</tc:Cep>
75
+ </tc:Endereco>
76
+ </tc:Tomador>
77
+ </tc:InfRps>
78
+ </tc:Rps>
79
+ </tc:ListaRps>
80
+ </LoteRps>
81
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
82
+ <SignedInfo>
83
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
84
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
85
+ <Reference>
86
+ <Transforms>
87
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
88
+ </Transforms>
89
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
90
+ <DigestValue>wBKH90N6CSrgbPo134OwY7xPFX8=</DigestValue>
91
+ </Reference>
92
+ </SignedInfo>
93
+ <SignatureValue>EkvAUi/aZQ8CjfDr3Iys33HJ0Gkd2Iu0vVGQ3OL68OX6XDHAZhVF++GNYqfvla5j
94
+ z9jFsTLUetNGyMwQZXB//0RPff3nL4SEQ1qypM0SECu1aTtRlra2crCjv12wghde
95
+ pa0C//DXGkqX52LOsIbDZtHf0l+56JMaIVS9YW79aQfJq0XxthvjMH68TGClb9r+
96
+ 3kKvMI6qy8ym21niEJiuoW5Q4u1CXmNfk/Q30ZRlp97+bXR0xi7DxI1V9di5lRMh
97
+ 77Ih/2tH2cPkDZp/0/H2WNc90tVMYyZnzBKdKG+nIMPXUeGbQKEO9c8knrUHhA17
98
+ FPMQAPRpWlxE0XVnJb0mDA==</SignatureValue>
99
+ <KeyInfo>
100
+ <X509Data>
101
+ <X509Certificate>MIIH7jCCBdagAwIBAgIIebwmN9dD4mUwDQYJKoZIhvcNAQELBQAwTDELMAkGA1UE
102
+ BhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxKDAmBgNVBAMTH1NFUkFTQSBDZXJ0
103
+ aWZpY2Fkb3JhIERpZ2l0YWwgd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hSHrAtvtOw0Pm+
134
+ B8/rAEagE9GCV4LBobGKQLfuzWk75ppULFHEVHT4HuW9zkxAUU42M7qTxZN3vi9X
135
+ 048TqAukgGtBFqMyDIvNAJJYZsHzIn8SS1IYWVP/+dgCzYC0l54U+HcK9N8KEypU
136
+ v0BZ+ZQkjjuU7KTOpDn7OwE2L009KKh/WETjElTIDa7EjUeguLgBnbPUImGU9SNc
137
+ a7SIxXssFQQV78tWgfJYovmzTMCrd9WDezRNtvYY5Nk++9A/m0ro2efahd9uZJoO
138
+ IihIXSanv5ChGITRUW5ADckfmMOkhmZAXpizDsjhl1DjeVPQ33imHe7PsX6cvP1Q
139
+ C28YHJ7OwCr3MTjFybxCe8w9Wtw5pobu4S9sC6H4yZQIIWywZWS9z8dMGfreTGtS
140
+ jsr2ACd5QFUk7a8bCXHF0hKmpcXhIQrCCJimwXHLarRJgjcFXm/SgIlxvAlzm1N7
141
+ MVtDqPwyb4gtLpbxUnHFVqC3Gd8M1QD4gTnjIELR/cIF6VelzISDE1mpiKNAK5Uq
142
+ wDQ51Yr8gzAVv6YJzf3eeMY+UaalrhF0TjteWzEdsn4dp9nX3K2qzx3BlQ4fQfbJ
143
+ AZNA4jQj/HCGCNKespYVBi6x</X509Certificate>
144
+ </X509Data>
145
+ </KeyInfo>
146
+ </Signature>
147
+ </EnviarLoteRpsEnvio>
148
+ ]]></xml></RecepcionarLoteRps></soap:Body></soap:Envelope>
149
+ headers:
150
+ Soapaction:
151
+ - '"RecepcionarLoteRps"'
152
+ Content-Type:
153
+ - application/soap+xml;charset=UTF-8
154
+ Content-Length:
155
+ - '7185'
156
+ Accept-Encoding:
157
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
158
+ Accept:
159
+ - "*/*"
160
+ User-Agent:
161
+ - Ruby
162
+ response:
163
+ status:
164
+ code: 200
165
+ message: OK
166
+ headers:
167
+ Date:
168
+ - Fri, 11 Jul 2014 07:16:20 GMT
169
+ Server:
170
+ - Microsoft-IIS/6.0
171
+ X-Powered-By:
172
+ - ASP.NET
173
+ X-Aspnet-Version:
174
+ - 2.0.50727
175
+ Cache-Control:
176
+ - private, max-age=0
177
+ Content-Type:
178
+ - application/soap+xml; charset=utf-8
179
+ Content-Length:
180
+ - '1256'
181
+ body:
182
+ encoding: ASCII-8BIT
183
+ string: !binary |-
184
+ PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c29hcDpF
185
+ bnZlbG9wZSB4bWxuczpzb2FwPSJodHRwOi8vd3d3LnczLm9yZy8yMDAzLzA1
186
+ L3NvYXAtZW52ZWxvcGUiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcv
187
+ MjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3
188
+ dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiPjxzb2FwOkJvZHk+PFJlY2VwY2lv
189
+ bmFyTG90ZVJwc1Jlc3BvbnNlIHhtbG5zPSJodHRwOi8vd3d3Lmlzc25ldG9u
190
+ bGluZS5jb20uYnIvd2Vic2VydmljZS9uZmQiPjxSZWNlcGNpb25hckxvdGVS
191
+ cHNSZXN1bHQ+Jmx0Oz94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRm
192
+ LTgiPyZndDsNCiZsdDtFbnZpYXJMb3RlUnBzUmVzcG9zdGEgeG1sbnM9Imh0
193
+ dHA6Ly93d3cuaXNzbmV0b25saW5lLmNvbS5ici93ZWJzZXJ2aWNlYWJyYXNm
194
+ L3ZzZC9zZXJ2aWNvX2Vudmlhcl9sb3RlX3Jwc19yZXNwb3N0YS54c2QiJmd0
195
+ Ow0KICAmbHQ7TGlzdGFNZW5zYWdlbVJldG9ybm8mZ3Q7DQogICAgJmx0O01l
196
+ bnNhZ2VtUmV0b3JubyZndDsNCiAgICAgICZsdDtDb2RpZ28geG1sbnM9Imh0
197
+ dHA6Ly93d3cuaXNzbmV0b25saW5lLmNvbS5ici93ZWJzZXJ2aWNlYWJyYXNm
198
+ L3ZzZC90aXBvc19jb21wbGV4b3MueHNkIiZndDtFMTU3Jmx0Oy9Db2RpZ28m
199
+ Z3Q7DQogICAgICAmbHQ7TWVuc2FnZW0geG1sbnM9Imh0dHA6Ly93d3cuaXNz
200
+ bmV0b25saW5lLmNvbS5ici93ZWJzZXJ2aWNlYWJyYXNmL3ZzZC90aXBvc19j
201
+ b21wbGV4b3MueHNkIiZndDsgVXN1w6FyaW8gbsOjbyBlc3TDoSBhdXRvcml6
202
+ YWRvIGEgdXRpbGl6YXIgZXNzZSBzZXJ2acOnbyBwYXJhIGVzc2UgY29udHJp
203
+ YnVpbnRlLiAmbHQ7L01lbnNhZ2VtJmd0Ow0KICAgICAgJmx0O0NvcnJlY2Fv
204
+ IHhtbG5zPSJodHRwOi8vd3d3Lmlzc25ldG9ubGluZS5jb20uYnIvd2Vic2Vy
205
+ dmljZWFicmFzZi92c2QvdGlwb3NfY29tcGxleG9zLnhzZCImZ3Q7U29saWNp
206
+ dGUgYW8gY29udHJpYnVpbnRlIGF1dG9yaXphw6fDo28gcGFyYSB1dGlsaXph
207
+ ciBvIHNlcnZpw6dvIGVtIHNldSBub21lLiZsdDsvQ29ycmVjYW8mZ3Q7DQog
208
+ ICAgJmx0Oy9NZW5zYWdlbVJldG9ybm8mZ3Q7DQogICZsdDsvTGlzdGFNZW5z
209
+ YWdlbVJldG9ybm8mZ3Q7DQombHQ7L0VudmlhckxvdGVScHNSZXNwb3N0YSZn
210
+ dDs8L1JlY2VwY2lvbmFyTG90ZVJwc1Jlc3VsdD48L1JlY2VwY2lvbmFyTG90
211
+ ZVJwc1Jlc3BvbnNlPjwvc29hcDpCb2R5Pjwvc29hcDpFbnZlbG9wZT4=
212
+ http_version:
213
+ recorded_at: Fri, 11 Jul 2014 07:16:22 GMT
214
+ recorded_with: VCR 2.9.2
data/spec/hash_spec.rb ADDED
@@ -0,0 +1,205 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Rnfse::Hash do
5
+
6
+ describe '::transform_keys' do
7
+ context 'com um hash simples,' do
8
+ let(:hash) { { name: 'Rob', age: '28' } }
9
+ let(:transformed_hash) { { 'NAME' => 'Rob', 'AGE' => '28' } }
10
+ it { expect(Rnfse::Hash.transform_keys(hash){ |key| key.to_s.upcase}).to eq(transformed_hash) }
11
+ end
12
+
13
+ context 'com um hash dentro de outro,' do
14
+ let(:hash) { { name: { first: 'Rob', last: 'Zombie' } } }
15
+ let(:transformed_hash) { { 'NAME' => { 'FIRST' => 'Rob', 'LAST' => 'Zombie' } } }
16
+ it { expect(Rnfse::Hash.transform_keys(hash){ |key| key.to_s.upcase}).to eq(transformed_hash) }
17
+ end
18
+
19
+ context 'com um array com outros objetos,' do
20
+ let(:hash) { { names: [ { first: 'Glados' }, { first: 'Wheatley' } ] } }
21
+ let(:transformed_hash) { { 'NAMES' => [ { 'FIRST' => 'Glados' }, { 'FIRST' => 'Wheatley' } ] } }
22
+ it { expect(Rnfse::Hash.transform_keys(hash){ |key| key.to_s.upcase}).to eq(transformed_hash) }
23
+ end
24
+ end
25
+
26
+ describe '#transform_keys' do
27
+ let(:hash) { Rnfse::Hash.new({ name: 'Rob', age: '28' }) }
28
+ let(:transformed_hash) { { 'NAME' => 'Rob', 'AGE' => '28' } }
29
+ it { expect(hash.transform_keys { |key| key.to_s.upcase}).to eq(transformed_hash) }
30
+ end
31
+
32
+ describe '::symbolize_keys' do
33
+ let(:hash) { { 'name' => 'Rob', 'age' => '28' } }
34
+ let(:transformed_hash) { { name: 'Rob', age: '28' } }
35
+ it { expect(Rnfse::Hash.symbolize_keys(hash)).to eq(transformed_hash) }
36
+ end
37
+
38
+ describe '#symbolize_keys' do
39
+ let(:hash) { Rnfse::Hash.new({ 'name' => 'Rob', 'age' => '28' }) }
40
+ let(:transformed_hash) { { name: 'Rob', age: '28' } }
41
+ it { expect(hash.symbolize_keys).to eq(transformed_hash) }
42
+ end
43
+
44
+ describe '::stringify_keys' do
45
+ let(:hash) { { name: 'Rob', age: '28' } }
46
+ let(:transformed_hash) { { 'name' => 'Rob', 'age' => '28' } }
47
+ it { expect(Rnfse::Hash.stringify_keys(hash)).to eq(transformed_hash) }
48
+ end
49
+
50
+ describe '#stringify_keys' do
51
+ let(:hash) { Rnfse::Hash.new({ name: 'Rob', age: '28' }) }
52
+ let(:transformed_hash) { { 'name' => 'Rob', 'age' => '28' } }
53
+ it { expect(hash.stringify_keys).to eq(transformed_hash) }
54
+ end
55
+
56
+ describe '::camelize_and_symbolize_keys' do
57
+ let(:hash) { { 'first_name' => 'Rob', 'current_age' => '28' } }
58
+ let(:transformed_hash) { { FirstName: 'Rob', CurrentAge: '28' } }
59
+ it { expect(Rnfse::Hash.camelize_and_symbolize_keys(hash)).to eq(transformed_hash) }
60
+ end
61
+
62
+ describe '#camelize_and_symbolize_keys' do
63
+ let(:hash) { Rnfse::Hash.new({ 'first_name' => 'Rob', 'current_age' => '28' }) }
64
+ let(:transformed_hash) { { FirstName: 'Rob', CurrentAge: '28' } }
65
+ it { expect(hash.camelize_and_symbolize_keys).to eq(transformed_hash) }
66
+ end
67
+
68
+ describe '::underscore_and_symbolize_keys' do
69
+ let(:hash) { { 'first_name' => 'Rob', 'currentAge' => '28' } }
70
+ let(:transformed_hash) { { first_name: 'Rob', current_age: '28' } }
71
+ it { expect(Rnfse::Hash.underscore_and_symbolize_keys(hash)).to eq(transformed_hash) }
72
+ end
73
+
74
+ describe '#underscore_and_symbolize_keys' do
75
+ let(:hash) { Rnfse::Hash.new({ 'first_name' => 'Rob', 'currentAge' => '28' }) }
76
+ let(:transformed_hash) { { first_name: 'Rob', current_age: '28' } }
77
+ it { expect(hash.underscore_and_symbolize_keys).to eq(transformed_hash) }
78
+ end
79
+
80
+ describe '::transform_values' do
81
+ context 'com um hash simples,' do
82
+ let(:hash) { { name: 'Rob', age: '28' } }
83
+ let(:transformed_hash) { { name: 'ROB', age: '28' } }
84
+ it { expect(
85
+ Rnfse::Hash.transform_values(hash, :name) { |val|
86
+ val.to_s.upcase
87
+ }).to eq(transformed_hash)
88
+ }
89
+ end
90
+
91
+ context 'com um hash dentro de outro,' do
92
+ let(:hash) { { name: { first: 'Rob', last: 'Zombie' } } }
93
+ let(:transformed_hash) { { name: { first: 'Rob', last: 'ZOMBIE' } } }
94
+ it { expect(
95
+ Rnfse::Hash.transform_values(hash, :last) { |val|
96
+ val.to_s.upcase
97
+ }).to eq(transformed_hash)
98
+ }
99
+ end
100
+
101
+ context 'com um hash e array com outros objetos,' do
102
+ let(:hash) { { first: 'Aperture', names: [ { first: 'Glados' } ] } }
103
+ let(:transformed_hash) { { first: 'APERTURE', names: [ { first: 'GLADOS' } ] } }
104
+ it { expect(
105
+ Rnfse::Hash.transform_values(hash, :first) { |val|
106
+ val.to_s.upcase
107
+ }).to eq(transformed_hash)
108
+ }
109
+ end
110
+
111
+ context 'com um array com outros objetos,' do
112
+ let(:hash) { { names: [ { first: 'Glados' }, { first: 'Wheatley' } ] } }
113
+ let(:transformed_hash) { { names: [ { first: 'GLADOS' }, { first: 'WHEATLEY' } ] } }
114
+ it { expect(
115
+ Rnfse::Hash.transform_values(hash, :first) { |val|
116
+ val.to_s.upcase
117
+ }).to eq(transformed_hash)
118
+ }
119
+ end
120
+
121
+ context 'com um regex como valor,' do
122
+ let(:hash) { { names: [ { first_name: 'Glados' }, { first: 'Wheatley' } ] } }
123
+ let(:transformed_hash) { { names: [ { first_name: 'GLADOS' }, { first: 'Wheatley' } ] } }
124
+ it { expect(
125
+ Rnfse::Hash.transform_values(hash, /first_/) { |val|
126
+ val.to_s.upcase
127
+ }).to eq(transformed_hash)
128
+ }
129
+ end
130
+ end
131
+
132
+ describe '#transform_values' do
133
+ let(:hash) { Rnfse::Hash.new({ name: 'Rob', age: '28' }) }
134
+ let(:transformed_hash) { { name: 'ROB', age: '28' } }
135
+ it { expect(
136
+ hash.transform_values(:name) { |val|
137
+ val.to_s.upcase
138
+ }).to eq(transformed_hash)
139
+ }
140
+ end
141
+
142
+ describe '::replace_key_values' do
143
+ context 'com um hash simples,' do
144
+ let(:hash) { { name: 'Rob', age: '28' } }
145
+ let(:transformed_hash) { { first: { name: 'Rob' }, age: '28' } }
146
+ it { expect(
147
+ Rnfse::Hash.replace_key_values(hash, :name) { |key, value|
148
+ { first: { key => value } }
149
+ }).to eq(transformed_hash)
150
+ }
151
+ end
152
+
153
+ context 'com um hash dentro de outro,' do
154
+ let(:hash) { { name: { first: 'Rob', last: 'Zombie' } } }
155
+ let(:transformed_hash) { { name: { strong: { first: 'Rob' }, last: 'Zombie' } } }
156
+ it { expect(
157
+ Rnfse::Hash.replace_key_values(hash, :first) { |key, value|
158
+ { strong: { key => value } }
159
+ }).to eq(transformed_hash)
160
+ }
161
+ end
162
+
163
+ context 'com um array com outros objetos,' do
164
+ let(:hash) { { names: [ { first: 'Glados' }, { second: 'Wheatley' } ] } }
165
+ let(:transformed_hash) { { names: [ { strong: { first: 'Glados' } }, { second: 'Wheatley' } ] } }
166
+ it { expect(
167
+ Rnfse::Hash.replace_key_values(hash, :first) { |key, value|
168
+ { strong: { key => value } }
169
+ }).to eq(transformed_hash)
170
+ }
171
+ end
172
+
173
+ context 'com um regex como valor,' do
174
+ let(:hash) { { names: [ { first_name: 'Glados' }, { second: 'Wheatley' } ] } }
175
+ let(:transformed_hash) { { names: [ { strong: { first_name: 'Glados' } }, { second: 'Wheatley' } ] } }
176
+ it { expect(
177
+ Rnfse::Hash.replace_key_values(hash, /first/) { |key, value|
178
+ { strong: { key => value } }
179
+ }).to eq(transformed_hash)
180
+ }
181
+ end
182
+
183
+ context 'com um escopo de tag definido' do
184
+ let(:hash) { { names: { first: 'Glados' }, nicknames: { first: 'Wheatley' } } }
185
+ let(:transformed_hash) { { names: { first: 'GLADOS' }, nicknames: { first: 'Wheatley' } } }
186
+
187
+ it { expect(
188
+ Rnfse::Hash.replace_key_values(hash, 'names/first') { |key, value|
189
+ { key => value.upcase }
190
+ }).to eq(transformed_hash)
191
+ }
192
+ end
193
+ end
194
+
195
+ describe '#replace_key_values' do
196
+ let(:hash) { Rnfse::Hash.new({ name: 'Rob', age: '28' }) }
197
+ let(:transformed_hash) { { first: { name: 'Rob' }, age: '28' } }
198
+ it { expect(
199
+ hash.replace_key_values(:name) { |key, value|
200
+ { first: { key => value } }
201
+ }).to eq(transformed_hash)
202
+ }
203
+ end
204
+
205
+ end
@@ -0,0 +1,29 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+ end
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+ require 'webmock'
9
+ require 'vcr'
10
+ VCR.configure do |c|
11
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
12
+ c.hook_into :webmock
13
+ WebMock.allow_net_connect!
14
+ end
15
+
16
+ lib = File.expand_path('../lib', __FILE__)
17
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
18
+ $ROOT = File.expand_path('../..', __FILE__)
19
+
20
+ require 'rspec/its'
21
+ require 'rspec/matchers'
22
+ require 'equivalent-xml'
23
+ require 'rnfse'
24
+
25
+ Dir[File.join(File.expand_path(File.dirname(__FILE__)), "support", "**", "*.rb")].each {|f| require f}
26
+
27
+ RSpec.configure do |config|
28
+ config.mock_with :rspec
29
+ end
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Rnfse::String do
5
+ describe '::camelize' do
6
+ context 'quando uma string simples,' do
7
+ let(:string) { 'portals' }
8
+ let(:camelized_string) { 'Portals' }
9
+ it { expect(Rnfse::String.camelize(string)).to eq(camelized_string) }
10
+ end
11
+
12
+ context 'quando uma string com undescore,' do
13
+ let(:string) { 'portals_two' }
14
+ let(:camelized_string) { 'PortalsTwo' }
15
+ it { expect(Rnfse::String.camelize(string)).to eq(camelized_string) }
16
+ end
17
+ end
18
+
19
+ describe '#camelize' do
20
+ let(:string) { Rnfse::String.new('portals') }
21
+ let(:camelized_string) { 'Portals' }
22
+ it { expect(string.camelize).to eq(camelized_string) }
23
+ end
24
+
25
+ describe '::underscore' do
26
+ context 'quando uma palavra em CamelCase' do
27
+ let(:string) { 'CamelCase' }
28
+ let(:underscored_string) { 'camel_case' }
29
+ it { expect(Rnfse::String.underscore(string)).to eq(underscored_string) }
30
+ end
31
+ end
32
+
33
+ describe '#underscore' do
34
+ let(:string) { Rnfse::String.new('CamelCase') }
35
+ let(:underscored_string) { 'camel_case' }
36
+ it { expect(string.underscore).to eq(underscored_string) }
37
+ end
38
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rnfse do
4
+ it { expect(Rnfse::VERSION).not_to be_nil }
5
+ end
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Rnfse::XMLBuilder::Abrasf10 do
5
+
6
+ let(:builder) { Rnfse::XMLBuilder.new(padrao: :abrasf_1_0) }
7
+
8
+ describe "#build_recepcionar_lote_rps_xml" do
9
+ let(:xml) do
10
+ Nokogiri::XML(
11
+ File.read(
12
+ File.join($ROOT, 'spec', 'fixtures', 'abrasf_1_0',
13
+ 'enviar_lote_rps_envio.xml')
14
+ )
15
+ )
16
+ end
17
+
18
+ subject do
19
+ builder.build_recepcionar_lote_rps_xml({
20
+ lote_rps: {
21
+ numero_lote: 2,
22
+ cnpj: "44.141.526/0001-67",
23
+ inscricao_municipal: "12345678",
24
+ quantidade_rps: 1,
25
+ lista_rps: [
26
+ {
27
+ identificacao_rps: { numero: 2, serie: "8", tipo: 1 },
28
+ data_emissao: "1960-04-21T21:42:42-03:00",
29
+ natureza_operacao: 1,
30
+ optante_simples_nacional: false,
31
+ incentivador_cultural: false,
32
+ status: 1,
33
+ servico: {
34
+ valores: {
35
+ valor_servicos: 10.42,
36
+ iss_retido: false,
37
+ base_calculo: 10.42
38
+ },
39
+ item_lista_servico: "00001",
40
+ discriminacao: "Borealis",
41
+ codigo_municipio: 5300108
42
+ },
43
+ prestador: {
44
+ cnpj: "44.141.526/0001-67",
45
+ inscricao_municipal: "12345678"
46
+ },
47
+ tomador: {
48
+ identificacao_tomador: {
49
+ cnpj: "38.421.846/0001-78",
50
+ inscricao_municipal: "12345679"
51
+ }
52
+ }
53
+ }
54
+ ]
55
+ }
56
+ })
57
+ end
58
+
59
+ it { should be_equivalent_to(xml) }
60
+ it { should be_kind_of(Nokogiri::XML::Document) }
61
+ end
62
+
63
+ end