rnfse 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +7 -6
  4. data/lib/provedores.yml +8 -0
  5. data/lib/rnfse.rb +5 -1
  6. data/lib/rnfse/api.rb +44 -22
  7. data/lib/rnfse/api/abrasf_1_0.rb +100 -17
  8. data/lib/rnfse/api/abrasf_1_0/#definitions.json# +413 -0
  9. data/lib/rnfse/api/abrasf_1_0/cancelar_nfse.json +13 -0
  10. data/lib/rnfse/api/abrasf_1_0/consultar_nfse.json +17 -0
  11. data/lib/rnfse/api/abrasf_1_0/consultar_nfse_por_rps.json +13 -0
  12. data/lib/rnfse/api/abrasf_1_0/definitions.json +27 -3
  13. data/lib/rnfse/api/abrasf_1_0/recepcionar_lote_rps.json +1 -1
  14. data/lib/rnfse/api/iss_net_1_0.rb +46 -2
  15. data/lib/rnfse/api/speed_gov_1_0.rb +115 -0
  16. data/lib/rnfse/call_chain.rb +4 -4
  17. data/lib/rnfse/error.rb +15 -0
  18. data/lib/rnfse/hash.rb +24 -11
  19. data/lib/rnfse/string.rb +16 -2
  20. data/lib/rnfse/version.rb +1 -1
  21. data/lib/rnfse/xml_builder/abrasf_1_0.rb +103 -13
  22. data/lib/rnfse/xml_builder/iss_net_1_0.rb +34 -4
  23. data/lib/rnfse/xml_builder/speed_gov_1_0.rb +158 -0
  24. data/spec/api/abrasf_1_0/cancelar_nfse_json_spec.rb +25 -0
  25. data/spec/api/abrasf_1_0/consultar_lote_rps_json_spec.rb +23 -0
  26. data/spec/api/abrasf_1_0/consultar_nfse_json_spec.rb +45 -0
  27. data/spec/api/abrasf_1_0/consultar_nfse_por_rps_json_spec.rb +23 -0
  28. data/spec/api/abrasf_1_0/consultar_situacao_lote_rps_json_spec.rb +23 -0
  29. data/spec/api/abrasf_1_0_spec.rb +185 -6
  30. data/spec/api/iss_net_1_0_spec.rb +89 -9
  31. data/spec/api/speed_gov_1_0_spec.rb +243 -0
  32. data/spec/api_spec.rb +43 -28
  33. data/spec/error_spec.rb +10 -0
  34. data/spec/fixtures/abrasf_1_0/cancelar_nfse_envio.xml +16 -0
  35. data/spec/fixtures/abrasf_1_0/consultar_nfse.xml +23 -0
  36. data/spec/fixtures/abrasf_1_0/consultar_nfse_por_rps.xml +14 -0
  37. data/spec/fixtures/iss_net_1_0/cancelar_nfse_envio.xml +17 -0
  38. data/spec/fixtures/iss_net_1_0/consultar_nfse.xml +29 -0
  39. data/spec/fixtures/iss_net_1_0/consultar_nfse_por_rps.xml +17 -0
  40. data/spec/fixtures/speed_gov_1_0/consultar_nfse_envio.xml +29 -0
  41. data/spec/fixtures/speed_gov_1_0/consultar_nfse_rps_envio.xml +16 -0
  42. data/spec/fixtures/speed_gov_1_0/consultar_situacao_lote_rps_envio.xml +12 -0
  43. data/spec/fixtures/speed_gov_1_0/enviar_lote_rps_envio.xml +82 -0
  44. data/spec/fixtures/speed_gov_1_0/header.xml +9 -0
  45. data/spec/fixtures/vcr_cassettes/iss_net_1_0_cancelar_nfse.yml +107 -0
  46. data/spec/fixtures/vcr_cassettes/iss_net_1_0_consultar_nfse.yml +7937 -0
  47. data/spec/fixtures/vcr_cassettes/iss_net_1_0_consultar_nfse_por_rps.yml +242 -0
  48. data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_nfse.yml +60 -0
  49. data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_nfse_por_rps.yml +80 -0
  50. data/spec/fixtures/vcr_cassettes/speed_gov_1_0_consultar_situacao_lote_rps.yml +77 -0
  51. data/spec/fixtures/vcr_cassettes/speed_gov_1_0_recepcionar_lote_rps.yml +171 -0
  52. data/spec/fixtures/vcr_cassettes/speed_gov_1_0_recepcionar_lote_rps_ascii.yml +171 -0
  53. data/spec/hash_spec.rb +21 -0
  54. data/spec/spec_helper.rb +2 -0
  55. data/spec/string_spec.rb +31 -5
  56. data/spec/xml_builder/abrasf_1_0_spec.rb +110 -43
  57. data/spec/xml_builder/iss_net_1_0_spec.rb +111 -44
  58. data/spec/xml_builder/speed_gov_1_0_spec.rb +173 -0
  59. metadata +86 -37
  60. data/.gitignore +0 -25
  61. data/.rspec +0 -1
  62. data/.travis.yml +0 -14
  63. data/Gemfile +0 -3
  64. data/Guardfile +0 -15
  65. data/Procfile +0 -1
  66. data/Rakefile +0 -12
  67. data/rnfse.gemspec +0 -61
  68. data/spec/fixtures/abrasf_1_0/teste.xml +0 -8
  69. data/spec/support/.keep +0 -0
@@ -0,0 +1,171 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://speedgov.com.br/wsmod/Nfes
6
+ body:
7
+ encoding: UTF-8
8
+ string: |-
9
+ <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nfse="http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd"><soapenv:Body><nfse:RecepcionarLoteRps><header><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
10
+ <p:cabecalho xmlns:p="http://ws.speedgov.com.br/cabecalho_v1.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p1="http://ws.speedgov.com.br/tipos_v1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" versao="1" xsi:schemaLocation="http://ws.speedgov.com.br/cabecalho_v1.xsd">
11
+ <versaoDados>1</versaoDados>
12
+ </p:cabecalho>
13
+ ]]></header><parameters><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
14
+ <p:EnviarLoteRpsEnvio xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p1="http://ws.speedgov.com.br/tipos_v1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd" xsi:schemaLocation="http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd">
15
+ <p:LoteRps>
16
+ <p1:NumeroLote>1</p1:NumeroLote>
17
+ <p1:Cnpj>12552510000150</p1:Cnpj>
18
+ <p1:InscricaoMunicipal>68</p1:InscricaoMunicipal>
19
+ <p1:QuantidadeRps>1</p1:QuantidadeRps>
20
+ <p1:ListaRps>
21
+ <p1:Rps>
22
+ <p1:InfRps>
23
+ <p1:IdentificacaoRps>
24
+ <p1:Numero>1</p1:Numero>
25
+ <p1:Serie>00000</p1:Serie>
26
+ <p1:Tipo>1</p1:Tipo>
27
+ </p1:IdentificacaoRps>
28
+ <p1:DataEmissao>2013-10-01T08:10:00</p1:DataEmissao>
29
+ <p1:NaturezaOperacao>1</p1:NaturezaOperacao>
30
+ <p1:OptanteSimplesNacional>2</p1:OptanteSimplesNacional>
31
+ <p1:IncentivadorCultural>2</p1:IncentivadorCultural>
32
+ <p1:Status>1</p1:Status>
33
+ <p1:Servico>
34
+ <p1:Valores>
35
+ <p1:ValorServicos>500.0</p1:ValorServicos>
36
+ <p1:ValorDeducoes>0.0</p1:ValorDeducoes>
37
+ <p1:ValorPis>0.0</p1:ValorPis>
38
+ <p1:ValorCofins>0.0</p1:ValorCofins>
39
+ <p1:ValorInss>0.0</p1:ValorInss>
40
+ <p1:ValorIr>0.0</p1:ValorIr>
41
+ <p1:ValorCsll>0.0</p1:ValorCsll>
42
+ <p1:IssRetido>2</p1:IssRetido>
43
+ <p1:ValorIss>10.0</p1:ValorIss>
44
+ <p1:ValorIssRetido>0.0</p1:ValorIssRetido>
45
+ <p1:OutrasRetencoes>0.0</p1:OutrasRetencoes>
46
+ <p1:BaseCalculo>500.0</p1:BaseCalculo>
47
+ <p1:Aliquota>2.0</p1:Aliquota>
48
+ <p1:ValorLiquidoNfse>490.0</p1:ValorLiquidoNfse>
49
+ <p1:DescontoCondicionado>0.0</p1:DescontoCondicionado>
50
+ <p1:DescontoIncondicionado>0.0</p1:DescontoIncondicionado>
51
+ </p1:Valores>
52
+ <p1:ItemListaServico>101</p1:ItemListaServico>
53
+ <p1:CodigoCnae>6201500</p1:CodigoCnae>
54
+ <p1:CodigoTributacaoMunicipio>620150000</p1:CodigoTributacaoMunicipio>
55
+ <p1:Discriminacao>Borealis</p1:Discriminacao>
56
+ <p1:CodigoMunicipio>9999999</p1:CodigoMunicipio>
57
+ </p1:Servico>
58
+ <p1:Prestador>
59
+ <p1:Cnpj>12552510000150</p1:Cnpj>
60
+ <p1:InscricaoMunicipal>68</p1:InscricaoMunicipal>
61
+ </p1:Prestador>
62
+ <p1:Tomador>
63
+ <p1:IdentificacaoTomador>
64
+ <p1:CpfCnpj>
65
+ <p1:Cnpj>12477945000188</p1:Cnpj>
66
+ </p1:CpfCnpj>
67
+ </p1:IdentificacaoTomador>
68
+ <p1:RazaoSocial>Black Mesa Research Facility</p1:RazaoSocial>
69
+ <p1:Endereco>
70
+ <p1:Endereco>RUA VICENTE F. GOES</p1:Endereco>
71
+ <p1:Numero>182</p1:Numero>
72
+ <p1:Complemento>A</p1:Complemento>
73
+ <p1:Bairro>ALTO DA MANGUEIRA</p1:Bairro>
74
+ <p1:CodigoMunicipio>9999999</p1:CodigoMunicipio>
75
+ <p1:Uf>CE</p1:Uf>
76
+ <p1:Cep>61900000</p1:Cep>
77
+ </p1:Endereco>
78
+ <p1:Contato>
79
+ <p1:Telefone>8512341234</p1:Telefone>
80
+ <p1:Email>teste@fes.com.br</p1:Email>
81
+ </p1:Contato>
82
+ </p1:Tomador>
83
+ <p1:IntermediarioServico>
84
+ <p1:RazaoSocial>Intersol Servicos Ltda</p1:RazaoSocial>
85
+ <p1:CpfCnpj>
86
+ <p1:Cpf>89746104349</p1:Cpf>
87
+ </p1:CpfCnpj>
88
+ <p1:InscricaoMunicipal>1234567</p1:InscricaoMunicipal>
89
+ </p1:IntermediarioServico>
90
+ </p1:InfRps>
91
+ </p1:Rps>
92
+ </p1:ListaRps>
93
+ </p:LoteRps>
94
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
95
+ <SignedInfo>
96
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
97
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
98
+ <Reference>
99
+ <Transforms>
100
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
101
+ </Transforms>
102
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
103
+ <DigestValue>i7o9RYh3bStKaJDhWX71JXdtmRo=</DigestValue>
104
+ </Reference>
105
+ </SignedInfo>
106
+ <SignatureValue>xPnp+hh9RTwUvCoYf+EFauRgeOmhfroxsYgbEe3wGLwPIQisNB2GMA/G5C0eVwiL
107
+ aOD4NqmZwaUXwYoTeXfYqdbRJT5+RlpxTxPYrUPDCD+m+zdb8eOSjK86bV/9TduJ
108
+ njdAv9DlcPhAQaMNG1R0IRwz0GVPWTwZ32yIIkTxjO4=</SignatureValue>
109
+ <KeyInfo>
110
+ <X509Data>
111
+ <X509Certificate>MIIC5jCCAk+gAwIBAgIJAMzd2iNeztRSMA0GCSqGSIb3DQEBCwUAMIGKMQswCQYD
112
+ VQQGEwJCUjEZMBcGA1UECAwQRGlzdHJpdG8gRmVkZXJhbDERMA8GA1UEBwwIQnJh
113
+ c2lsaWExDjAMBgNVBAoMBVJuZnNlMRkwFwYDVQQDDBBybmZzZS5naXRodWIuY29t
114
+ MSIwIAYJKoZIhvcNAQkBFhNhaXRoZXJpb3NAZ21haWwuY29tMCAXDTE0MDcxMDEx
115
+ MTMyOFoYDzIxMTQwNjE2MTExMzI4WjCBijELMAkGA1UEBhMCQlIxGTAXBgNVBAgM
116
+ EERpc3RyaXRvIEZlZGVyYWwxETAPBgNVBAcMCEJyYXNpbGlhMQ4wDAYDVQQKDAVS
117
+ bmZzZTEZMBcGA1UEAwwQcm5mc2UuZ2l0aHViLmNvbTEiMCAGCSqGSIb3DQEJARYT
118
+ YWl0aGVyaW9zQGdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
119
+ 1cQuK7bqd2w3ZslKWABFQHe3bD43b6SxWbI58ZXwM4VAOHjXJrSe1Ai2Yvd982gW
120
+ Ir9zjQf+CebzW7N/Es7maFQzFP9KlevRldUM8OTThJ6TEVvpLRgeIbgpRQ8bWKB0
121
+ lp3i6AggqCIQT8Q+5HG1bZn+8vjD1ZQ0lCZmyMX85w0CAwEAAaNQME4wHQYDVR0O
122
+ BBYEFGBEjuYDxQcIjemHCelvFmdD85cgMB8GA1UdIwQYMBaAFGBEjuYDxQcIjemH
123
+ CelvFmdD85cgMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEA1QQ8UFQT
124
+ UWRxR8sqmnguN+nQR6GtmDi6XCpgvP73TW68Em/lhdKjzP3RUy3Clw3qv+CV0ebI
125
+ BdHlq5kw12fb2XBVsls+PFnD6yQq9M8fUlUOLe4qz7mAIHw4iBS7I28uvoFsAvqE
126
+ 1ePe8pdP1RFvBMVm5fpduWR0h+z083Ytwkk=</X509Certificate>
127
+ </X509Data>
128
+ </KeyInfo>
129
+ </Signature>
130
+ </p:EnviarLoteRpsEnvio>
131
+ ]]></parameters></nfse:RecepcionarLoteRps></soapenv:Body></soapenv:Envelope>
132
+ headers:
133
+ Soapaction:
134
+ - '"RecepcionarLoteRps"'
135
+ Content-Type:
136
+ - text/xml;charset=UTF-8
137
+ Content-Length:
138
+ - '6351'
139
+ Accept-Encoding:
140
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
141
+ Accept:
142
+ - "*/*"
143
+ User-Agent:
144
+ - Ruby
145
+ response:
146
+ status:
147
+ code: 200
148
+ message: OK
149
+ headers:
150
+ Cache-Control:
151
+ - no-cache="set-cookie"
152
+ Content-Type:
153
+ - text/xml;charset=utf-8
154
+ Date:
155
+ - Thu, 14 Aug 2014 06:58:26 GMT
156
+ Server:
157
+ - Apache-Coyote/1.1
158
+ Set-Cookie:
159
+ - AWSELB=33FDC97B088EC7D48E554EA7951916335FCF4DD33354B9B00E5F1779243F06793B26A496916FB9C4F76E82B464490FEDD2D190D63CE7A0FA21188F78CC6FE9E7F20CBFCD5D;PATH=/
160
+ Transfer-Encoding:
161
+ - chunked
162
+ Connection:
163
+ - keep-alive
164
+ body:
165
+ encoding: UTF-8
166
+ string: |-
167
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:RecepcionarLoteRpsResponse xmlns:ns2="http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd"><return>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
168
+ &lt;RecepcionarLoteRpsResposta&gt;&lt;MensagemRetorno/&gt;&lt;NumeroLote&gt;1&lt;/NumeroLote&gt;&lt;DataRecebimento&gt;2014-08-04T09:34:21&lt;/DataRecebimento&gt;&lt;Protocolo&gt;2f3aa5f5-ccad-4136-8c27-c2fe490ad77f&lt;/Protocolo&gt;&lt;/RecepcionarLoteRpsResposta&gt;</return></ns2:RecepcionarLoteRpsResponse></S:Body></S:Envelope>
169
+ http_version:
170
+ recorded_at: Thu, 14 Aug 2014 06:58:28 GMT
171
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,171 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://speedgov.com.br/wsmod/Nfes
6
+ body:
7
+ encoding: UTF-8
8
+ string: |-
9
+ <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nfse="http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd"><soapenv:Body><nfse:RecepcionarLoteRps><header><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
10
+ <p:cabecalho xmlns:p="http://ws.speedgov.com.br/cabecalho_v1.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p1="http://ws.speedgov.com.br/tipos_v1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" versao="1" xsi:schemaLocation="http://ws.speedgov.com.br/cabecalho_v1.xsd">
11
+ <versaoDados>1</versaoDados>
12
+ </p:cabecalho>
13
+ ]]></header><parameters><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
14
+ <p:EnviarLoteRpsEnvio xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p1="http://ws.speedgov.com.br/tipos_v1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd" xsi:schemaLocation="http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd">
15
+ <p:LoteRps>
16
+ <p1:NumeroLote>1</p1:NumeroLote>
17
+ <p1:Cnpj>12552510000150</p1:Cnpj>
18
+ <p1:InscricaoMunicipal>68</p1:InscricaoMunicipal>
19
+ <p1:QuantidadeRps>1</p1:QuantidadeRps>
20
+ <p1:ListaRps>
21
+ <p1:Rps>
22
+ <p1:InfRps>
23
+ <p1:IdentificacaoRps>
24
+ <p1:Numero>1</p1:Numero>
25
+ <p1:Serie>00000</p1:Serie>
26
+ <p1:Tipo>1</p1:Tipo>
27
+ </p1:IdentificacaoRps>
28
+ <p1:DataEmissao>2013-10-01T08:10:00</p1:DataEmissao>
29
+ <p1:NaturezaOperacao>1</p1:NaturezaOperacao>
30
+ <p1:OptanteSimplesNacional>2</p1:OptanteSimplesNacional>
31
+ <p1:IncentivadorCultural>2</p1:IncentivadorCultural>
32
+ <p1:Status>1</p1:Status>
33
+ <p1:Servico>
34
+ <p1:Valores>
35
+ <p1:ValorServicos>500.0</p1:ValorServicos>
36
+ <p1:ValorDeducoes>0.0</p1:ValorDeducoes>
37
+ <p1:ValorPis>0.0</p1:ValorPis>
38
+ <p1:ValorCofins>0.0</p1:ValorCofins>
39
+ <p1:ValorInss>0.0</p1:ValorInss>
40
+ <p1:ValorIr>0.0</p1:ValorIr>
41
+ <p1:ValorCsll>0.0</p1:ValorCsll>
42
+ <p1:IssRetido>2</p1:IssRetido>
43
+ <p1:ValorIss>10.0</p1:ValorIss>
44
+ <p1:ValorIssRetido>0.0</p1:ValorIssRetido>
45
+ <p1:OutrasRetencoes>0.0</p1:OutrasRetencoes>
46
+ <p1:BaseCalculo>500.0</p1:BaseCalculo>
47
+ <p1:Aliquota>2.0</p1:Aliquota>
48
+ <p1:ValorLiquidoNfse>490.0</p1:ValorLiquidoNfse>
49
+ <p1:DescontoCondicionado>0.0</p1:DescontoCondicionado>
50
+ <p1:DescontoIncondicionado>0.0</p1:DescontoIncondicionado>
51
+ </p1:Valores>
52
+ <p1:ItemListaServico>101</p1:ItemListaServico>
53
+ <p1:CodigoCnae>6201500</p1:CodigoCnae>
54
+ <p1:CodigoTributacaoMunicipio>620150000</p1:CodigoTributacaoMunicipio>
55
+ <p1:Discriminacao>Borealis</p1:Discriminacao>
56
+ <p1:CodigoMunicipio>9999999</p1:CodigoMunicipio>
57
+ </p1:Servico>
58
+ <p1:Prestador>
59
+ <p1:Cnpj>12552510000150</p1:Cnpj>
60
+ <p1:InscricaoMunicipal>68</p1:InscricaoMunicipal>
61
+ </p1:Prestador>
62
+ <p1:Tomador>
63
+ <p1:IdentificacaoTomador>
64
+ <p1:CpfCnpj>
65
+ <p1:Cnpj>12477945000188</p1:Cnpj>
66
+ </p1:CpfCnpj>
67
+ </p1:IdentificacaoTomador>
68
+ <p1:RazaoSocial>Black Mesa Research Facility</p1:RazaoSocial>
69
+ <p1:Endereco>
70
+ <p1:Endereco>RUA VICENTE F. GOES</p1:Endereco>
71
+ <p1:Numero>182</p1:Numero>
72
+ <p1:Complemento>A</p1:Complemento>
73
+ <p1:Bairro>ALTO DA MANGUEIRA</p1:Bairro>
74
+ <p1:CodigoMunicipio>9999999</p1:CodigoMunicipio>
75
+ <p1:Uf>CE</p1:Uf>
76
+ <p1:Cep>61900000</p1:Cep>
77
+ </p1:Endereco>
78
+ <p1:Contato>
79
+ <p1:Telefone>8512341234</p1:Telefone>
80
+ <p1:Email>teste@fes.com.br</p1:Email>
81
+ </p1:Contato>
82
+ </p1:Tomador>
83
+ <p1:IntermediarioServico>
84
+ <p1:RazaoSocial>Intersol Servicos Ltda</p1:RazaoSocial>
85
+ <p1:CpfCnpj>
86
+ <p1:Cpf>89746104349</p1:Cpf>
87
+ </p1:CpfCnpj>
88
+ <p1:InscricaoMunicipal>1234567</p1:InscricaoMunicipal>
89
+ </p1:IntermediarioServico>
90
+ </p1:InfRps>
91
+ </p1:Rps>
92
+ </p1:ListaRps>
93
+ </p:LoteRps>
94
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
95
+ <SignedInfo>
96
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
97
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
98
+ <Reference>
99
+ <Transforms>
100
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
101
+ </Transforms>
102
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
103
+ <DigestValue>i7o9RYh3bStKaJDhWX71JXdtmRo=</DigestValue>
104
+ </Reference>
105
+ </SignedInfo>
106
+ <SignatureValue>xPnp+hh9RTwUvCoYf+EFauRgeOmhfroxsYgbEe3wGLwPIQisNB2GMA/G5C0eVwiL
107
+ aOD4NqmZwaUXwYoTeXfYqdbRJT5+RlpxTxPYrUPDCD+m+zdb8eOSjK86bV/9TduJ
108
+ njdAv9DlcPhAQaMNG1R0IRwz0GVPWTwZ32yIIkTxjO4=</SignatureValue>
109
+ <KeyInfo>
110
+ <X509Data>
111
+ <X509Certificate>MIIC5jCCAk+gAwIBAgIJAMzd2iNeztRSMA0GCSqGSIb3DQEBCwUAMIGKMQswCQYD
112
+ VQQGEwJCUjEZMBcGA1UECAwQRGlzdHJpdG8gRmVkZXJhbDERMA8GA1UEBwwIQnJh
113
+ c2lsaWExDjAMBgNVBAoMBVJuZnNlMRkwFwYDVQQDDBBybmZzZS5naXRodWIuY29t
114
+ MSIwIAYJKoZIhvcNAQkBFhNhaXRoZXJpb3NAZ21haWwuY29tMCAXDTE0MDcxMDEx
115
+ MTMyOFoYDzIxMTQwNjE2MTExMzI4WjCBijELMAkGA1UEBhMCQlIxGTAXBgNVBAgM
116
+ EERpc3RyaXRvIEZlZGVyYWwxETAPBgNVBAcMCEJyYXNpbGlhMQ4wDAYDVQQKDAVS
117
+ bmZzZTEZMBcGA1UEAwwQcm5mc2UuZ2l0aHViLmNvbTEiMCAGCSqGSIb3DQEJARYT
118
+ YWl0aGVyaW9zQGdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
119
+ 1cQuK7bqd2w3ZslKWABFQHe3bD43b6SxWbI58ZXwM4VAOHjXJrSe1Ai2Yvd982gW
120
+ Ir9zjQf+CebzW7N/Es7maFQzFP9KlevRldUM8OTThJ6TEVvpLRgeIbgpRQ8bWKB0
121
+ lp3i6AggqCIQT8Q+5HG1bZn+8vjD1ZQ0lCZmyMX85w0CAwEAAaNQME4wHQYDVR0O
122
+ BBYEFGBEjuYDxQcIjemHCelvFmdD85cgMB8GA1UdIwQYMBaAFGBEjuYDxQcIjemH
123
+ CelvFmdD85cgMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEA1QQ8UFQT
124
+ UWRxR8sqmnguN+nQR6GtmDi6XCpgvP73TW68Em/lhdKjzP3RUy3Clw3qv+CV0ebI
125
+ BdHlq5kw12fb2XBVsls+PFnD6yQq9M8fUlUOLe4qz7mAIHw4iBS7I28uvoFsAvqE
126
+ 1ePe8pdP1RFvBMVm5fpduWR0h+z083Ytwkk=</X509Certificate>
127
+ </X509Data>
128
+ </KeyInfo>
129
+ </Signature>
130
+ </p:EnviarLoteRpsEnvio>
131
+ ]]></parameters></nfse:RecepcionarLoteRps></soapenv:Body></soapenv:Envelope>
132
+ headers:
133
+ Soapaction:
134
+ - '"RecepcionarLoteRps"'
135
+ Content-Type:
136
+ - text/xml;charset=UTF-8
137
+ Content-Length:
138
+ - '6351'
139
+ Accept-Encoding:
140
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
141
+ Accept:
142
+ - "*/*"
143
+ User-Agent:
144
+ - Ruby
145
+ response:
146
+ status:
147
+ code: 200
148
+ message: OK
149
+ headers:
150
+ Cache-Control:
151
+ - no-cache="set-cookie"
152
+ Content-Type:
153
+ - text/xml;charset=utf-8
154
+ Date:
155
+ - Tue, 26 Aug 2014 23:29:24 GMT
156
+ Server:
157
+ - Apache-Coyote/1.1
158
+ Set-Cookie:
159
+ - AWSELB=33FDC97B088EC7D48E554EA7951916335FCF4DD33354B9B00E5F1779243F06793B26A49691A6E3300925177F1FEC0FFBE981FDDAACE7A0FA21188F78CC6FE9E7F20CBFCD5D;PATH=/
160
+ Content-Length:
161
+ - '609'
162
+ Connection:
163
+ - keep-alive
164
+ body:
165
+ encoding: UTF-8
166
+ string: |-
167
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:RecepcionarLoteRpsResponse xmlns:ns2="http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd"><return>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
168
+ &lt;RecepcionarLoteRpsResposta&gt;&lt;MensagemRetorno/&gt;&lt;NumeroLote&gt;1&lt;/NumeroLote&gt;&lt;DataRecebimento&gt;2014-08-04T09:34:21&lt;/DataRecebimento&gt;&lt;Protocolo&gt;2f3aa5f5-ccad-4136-8c27-c2fe490ad77f&lt;/Protocolo&gt;&lt;/RecepcionarLoteRpsResposta&gt;</return></ns2:RecepcionarLoteRpsResponse></S:Body></S:Envelope>
169
+ http_version:
170
+ recorded_at: Tue, 26 Aug 2014 23:29:27 GMT
171
+ recorded_with: VCR 2.9.2
@@ -21,6 +21,16 @@ describe Rnfse::Hash do
21
21
  let(:transformed_hash) { { 'NAMES' => [ { 'FIRST' => 'Glados' }, { 'FIRST' => 'Wheatley' } ] } }
22
22
  it { expect(Rnfse::Hash.transform_keys(hash){ |key| key.to_s.upcase}).to eq(transformed_hash) }
23
23
  end
24
+
25
+ context 'com um regex como valor,' do
26
+ let(:hash) { { names: [ { first_name: 'Glados' }, { first: 'Wheatley' } ] } }
27
+ let(:transformed_hash) { { names: [ { 'FIRST_NAME' => 'Glados' }, { first: 'Wheatley' } ] } }
28
+ it { expect(
29
+ Rnfse::Hash.transform_keys(hash, /first_/) { |key|
30
+ key.to_s.upcase
31
+ }).to eq(transformed_hash)
32
+ }
33
+ end
24
34
  end
25
35
 
26
36
  describe '#transform_keys' do
@@ -190,6 +200,17 @@ describe Rnfse::Hash do
190
200
  }).to eq(transformed_hash)
191
201
  }
192
202
  end
203
+
204
+ context 'com um array de regexes' do
205
+ let(:hash) { { names: { first: 'Glados' }, nicknames: { first: 'Wheatley' } } }
206
+ let(:transformed_hash) { { names: { first: 'GLADOS' }, nicknames: { first: 'Wheatley' } } }
207
+
208
+ it { expect(
209
+ Rnfse::Hash.replace_key_values(hash, [ /\Anames\Z/, /\Afirst\Z/ ]) { |key, value|
210
+ { key => value.upcase }
211
+ }).to eq(transformed_hash)
212
+ }
213
+ end
193
214
  end
194
215
 
195
216
  describe '#replace_key_values' do
@@ -10,6 +10,7 @@ require 'vcr'
10
10
  VCR.configure do |c|
11
11
  c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
12
12
  c.hook_into :webmock
13
+ # c.allow_http_connections_when_no_cassette = true
13
14
  c.ignore_hosts 'codeclimate.com'
14
15
  WebMock.allow_net_connect!
15
16
  end
@@ -18,6 +19,7 @@ lib = File.expand_path('../lib', __FILE__)
18
19
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
19
20
  $ROOT = File.expand_path('../..', __FILE__)
20
21
 
22
+ require 'pry'
21
23
  require 'rspec/its'
22
24
  require 'rspec/matchers'
23
25
  require 'equivalent-xml'
@@ -6,33 +6,59 @@ describe Rnfse::String do
6
6
  context 'quando uma string simples,' do
7
7
  let(:string) { 'portals' }
8
8
  let(:camelized_string) { 'Portals' }
9
- it { expect(Rnfse::String.camelize(string)).to eq(camelized_string) }
9
+ subject { Rnfse::String.camelize(string) }
10
+ it { is_expected.to eq(camelized_string) }
11
+ it { is_expected.to be_kind_of(Rnfse::String) }
10
12
  end
11
13
 
12
14
  context 'quando uma string com undescore,' do
13
15
  let(:string) { 'portals_two' }
14
16
  let(:camelized_string) { 'PortalsTwo' }
15
- it { expect(Rnfse::String.camelize(string)).to eq(camelized_string) }
17
+ subject { Rnfse::String.camelize(string) }
18
+ it { is_expected.to eq(camelized_string) }
19
+ it { is_expected.to be_kind_of(Rnfse::String) }
16
20
  end
17
21
  end
18
22
 
19
23
  describe '#camelize' do
20
24
  let(:string) { Rnfse::String.new('portals') }
21
25
  let(:camelized_string) { 'Portals' }
22
- it { expect(string.camelize).to eq(camelized_string) }
26
+ subject { string.camelize }
27
+ it { is_expected.to eq(camelized_string) }
28
+ it { is_expected.to be_kind_of(Rnfse::String) }
23
29
  end
24
30
 
25
31
  describe '::underscore' do
26
32
  context 'quando uma palavra em CamelCase' do
27
33
  let(:string) { 'CamelCase' }
28
34
  let(:underscored_string) { 'camel_case' }
29
- it { expect(Rnfse::String.underscore(string)).to eq(underscored_string) }
35
+ subject { Rnfse::String.underscore(string) }
36
+ it { is_expected.to eq(underscored_string) }
37
+ it { is_expected.to be_kind_of(Rnfse::String) }
30
38
  end
31
39
  end
32
40
 
33
41
  describe '#underscore' do
34
42
  let(:string) { Rnfse::String.new('CamelCase') }
35
43
  let(:underscored_string) { 'camel_case' }
36
- it { expect(string.underscore).to eq(underscored_string) }
44
+ subject { string.underscore }
45
+ it { is_expected.to eq(underscored_string) }
46
+ it { is_expected.to be_kind_of(Rnfse::String) }
47
+ end
48
+
49
+ describe '::demodulize' do
50
+ let(:string) { 'Rnfse::API::Abrasf10' }
51
+ let(:demodulized_string) { 'Abrasf10' }
52
+ subject { Rnfse::String.demodulize(string) }
53
+ it { is_expected.to eq(demodulized_string) }
54
+ it { is_expected.to be_kind_of(Rnfse::String) }
55
+ end
56
+
57
+ describe '#demodulize' do
58
+ let(:string) { Rnfse::String.new('Rnfse::API::Abrasf10') }
59
+ let(:demodulized_string) { 'Abrasf10' }
60
+ subject { string.demodulize }
61
+ it { is_expected.to eq(demodulized_string) }
62
+ it { is_expected.to be_kind_of(Rnfse::String) }
37
63
  end
38
64
  end