nfse_gyn 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -1
- data/README.md +2 -1
- data/lib/nfse_gyn/configuration.rb +9 -0
- data/lib/nfse_gyn/consultar_nfse.rb +5 -1
- data/lib/nfse_gyn/gerar_nfse.rb +5 -1
- data/lib/nfse_gyn/gerar_nfse_xml.rb +20 -15
- data/lib/nfse_gyn/mock_consultar_nfse_response.rb +77 -0
- data/lib/nfse_gyn/mock_gerar_nfse_response.rb +85 -0
- data/lib/nfse_gyn/response.rb +0 -1
- data/lib/nfse_gyn/soap_client.rb +3 -2
- data/lib/nfse_gyn/version.rb +1 -1
- data/lib/nfse_gyn.rb +4 -0
- data/nfse_gyn.gemspec +6 -5
- data/spec/lib/configuration_spec.rb +26 -0
- data/spec/lib/gerar_nfse_spec.rb +18 -2
- data/spec/lib/gerar_nfse_xml_spec.rb +4 -4
- metadata +24 -9
- data/spec/nfse_gyn_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8edeb97b674900d2d55bfe6079983a82928ce28d
|
4
|
+
data.tar.gz: 9a66234db94af251416151771705d6c795c21699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad16794f0150a07fd650c15c7c0e9fd1f8164a1557a2964208bcb08289b836a480c1d3557607601fcf113522fd1983ff55dd82fc6aad3cf08dca4824ce6dd073
|
7
|
+
data.tar.gz: d809f3cf8333b71cb5bd2037729f1c4bf8c8dc7e7ebaac014b4a01e424078cd97d4b42d29f0ecb139bf0b1f7d5d71d450e611513f9554fc69435734aef2c84b7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -47,7 +47,8 @@ Crie um arquivo `config/initializers/nfse_gyn.rb` e adicione:
|
|
47
47
|
```ruby
|
48
48
|
NfseGyn.configure do |nfse|
|
49
49
|
nfse.test_mode = true
|
50
|
-
nfse.
|
50
|
+
nfse.test_mode = true
|
51
|
+
nfse.log_level = :none
|
51
52
|
nfse.cnpj = '000000000000000'
|
52
53
|
nfse.inscricao_municipal = '0000000'
|
53
54
|
nfse.codigo_tributacao_municipio = '00000000'
|
@@ -2,6 +2,7 @@ module NfseGyn
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :wsdl,
|
4
4
|
:test_mode,
|
5
|
+
:mock_mode,
|
5
6
|
:log_level,
|
6
7
|
:ca_cert_path,
|
7
8
|
:cert_key_path,
|
@@ -16,6 +17,7 @@ module NfseGyn
|
|
16
17
|
|
17
18
|
def initialize
|
18
19
|
@test_mode = false
|
20
|
+
@mock_mode = false
|
19
21
|
@log_level = :debug
|
20
22
|
@wsdl = 'https://nfse.goiania.go.gov.br/ws/nfse.asmx?wsdl'
|
21
23
|
|
@@ -27,6 +29,13 @@ module NfseGyn
|
|
27
29
|
@codigo_tributacao_municipio = ''
|
28
30
|
end
|
29
31
|
|
32
|
+
def from_h(hash)
|
33
|
+
hash.each do |k, v|
|
34
|
+
instance_variable_set("@#{k}".to_sym, v)
|
35
|
+
end
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
30
39
|
def rps_serie
|
31
40
|
return 'TESTE' if test_mode
|
32
41
|
'A'
|
@@ -12,7 +12,11 @@ module NfseGyn
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def execute!
|
15
|
-
|
15
|
+
if NfseGyn.configuration.mock_mode
|
16
|
+
NfseGyn::MockConsultarNfseResponse.new(invoice_number, invoice_serie, invoice_type)
|
17
|
+
else
|
18
|
+
@client.call(:consultar_nfse_rps, self)
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
def to_xml
|
data/lib/nfse_gyn/gerar_nfse.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'active_support'
|
4
|
-
require 'active_support/core_ext'
|
5
3
|
require 'signer'
|
6
4
|
|
7
5
|
module NfseGyn
|
@@ -20,32 +18,32 @@ module NfseGyn
|
|
20
18
|
'InfDeclaracaoPrestacaoServico' => {
|
21
19
|
'@xmlns' => 'http://nfse.goiania.go.gov.br/xsd/nfse_gyn_v02.xsd',
|
22
20
|
'Rps' => {
|
23
|
-
'@Id' => @invoice[:identification_number],
|
21
|
+
'@Id' => raise_if_missing(@invoice[:identification_number], :identification_number),
|
24
22
|
'IdentificacaoRps' => {
|
25
23
|
'Numero' => @invoice[:identification_number],
|
26
|
-
'Serie' => NfseGyn.configuration.rps_serie,
|
27
|
-
'Tipo' => NfseGyn.configuration.rps_tipo
|
24
|
+
'Serie' => raise_if_missing(NfseGyn.configuration.rps_serie, :rps_serie),
|
25
|
+
'Tipo' => raise_if_missing(NfseGyn.configuration.rps_tipo, :rps_tipo)
|
28
26
|
},
|
29
|
-
'DataEmissao' => @invoice[:data_emissao],
|
27
|
+
'DataEmissao' => raise_if_missing(@invoice[:data_emissao], :data_emissao),
|
30
28
|
'Status' => 1
|
31
29
|
},
|
32
30
|
|
33
31
|
'Servico' => {
|
34
32
|
'Valores' => {
|
35
|
-
'ValorServicos' => @invoice[:total],
|
36
|
-
'Aliquota' => NfseGyn.configuration.valor_aliquota
|
33
|
+
'ValorServicos' => raise_if_missing(@invoice[:total], :total),
|
34
|
+
'Aliquota' => raise_if_missing(NfseGyn.configuration.valor_aliquota, :valor_aliquota)
|
37
35
|
},
|
38
36
|
|
39
|
-
'CodigoTributacaoMunicipio' => NfseGyn.configuration.codigo_tributacao_municipio,
|
40
|
-
'Discriminacao' => clear(@invoice[:description]),
|
41
|
-
'CodigoMunicipio' => NfseGyn.configuration.codigo_municipio
|
37
|
+
'CodigoTributacaoMunicipio' => raise_if_missing(NfseGyn.configuration.codigo_tributacao_municipio, :codigo_tributacao_municipio),
|
38
|
+
'Discriminacao' => raise_if_missing(clear(@invoice[:description]), :description),
|
39
|
+
'CodigoMunicipio' => raise_if_missing(NfseGyn.configuration.codigo_municipio, :codigo_municipio)
|
42
40
|
},
|
43
41
|
|
44
42
|
'Prestador' => {
|
45
43
|
'CpfCnpj' => {
|
46
|
-
'Cnpj' => NfseGyn.configuration.cnpj
|
44
|
+
'Cnpj' => raise_if_missing(NfseGyn.configuration.cnpj, :prestador_cnpj)
|
47
45
|
},
|
48
|
-
'InscricaoMunicipal' => NfseGyn.configuration.inscricao_municipal
|
46
|
+
'InscricaoMunicipal' => raise_if_missing(NfseGyn.configuration.inscricao_municipal, :prestador_inscricao_municipal)
|
49
47
|
},
|
50
48
|
|
51
49
|
'Tomador' => tomador
|
@@ -54,8 +52,15 @@ module NfseGyn
|
|
54
52
|
)
|
55
53
|
end
|
56
54
|
|
55
|
+
private
|
56
|
+
|
57
|
+
def raise_if_missing(param, param_name)
|
58
|
+
throw "Param #{param_name} is missing" if param.blank?
|
59
|
+
param
|
60
|
+
end
|
61
|
+
|
57
62
|
def sign(xml)
|
58
|
-
return xml if !certificate.present? || !private_key.present?
|
63
|
+
return xml if NfseGyn.configuration.mock_mode || !certificate.present? || !private_key.present?
|
59
64
|
signer = Signer.new(xml, canonicalize_algorithm: :c14n_1_0, wss: false)
|
60
65
|
signer.cert = OpenSSL::X509::Certificate.new(certificate)
|
61
66
|
signer.private_key = OpenSSL::PKey::RSA.new(private_key, NfseGyn.configuration.cert_key_password)
|
@@ -91,7 +96,7 @@ module NfseGyn
|
|
91
96
|
|
92
97
|
if document_type.present?
|
93
98
|
xml['IdentificacaoTomador'] = {
|
94
|
-
'CpfCnpj' => { document_type => document_number }
|
99
|
+
'CpfCnpj' => { document_type => raise_if_missing(document_number, :tomador_document_number)}
|
95
100
|
}
|
96
101
|
end
|
97
102
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module NfseGyn
|
2
|
+
class MockConsultarNfseResponse < NfseGyn::ConsultarNfse::Response
|
3
|
+
def initialize(_invoice_number, _invoice_serie, _invoice_type)
|
4
|
+
super(nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
def content
|
8
|
+
{
|
9
|
+
'CompNfse' => {
|
10
|
+
'Nfse' => {
|
11
|
+
'InfNfse' => {
|
12
|
+
'Numero' => '370',
|
13
|
+
'CodigoVerificacao' => 'MB94-C3ZA',
|
14
|
+
'DataEmissao' => @request[:data_emissao],
|
15
|
+
'OutrasInformacoes' => 'OUTRAS INFORMACOES SOBRE O SERVICO.',
|
16
|
+
'ValoresNfse' => {
|
17
|
+
'BaseCalculo' => '0',
|
18
|
+
'Aliquota' => '5',
|
19
|
+
'ValorIss' => '0'
|
20
|
+
}, 'DeclaracaoPrestacaoServico' => {
|
21
|
+
'IdentificacaoRps' => {
|
22
|
+
'Numero' => '14',
|
23
|
+
'Serie' => 'UNICA',
|
24
|
+
'Tipo' => '1'
|
25
|
+
},
|
26
|
+
'DataEmissao' => @request[:data_emissao],
|
27
|
+
'Competencia' => @request[:data_emissao],
|
28
|
+
'Servico' => {
|
29
|
+
'Valores' => {
|
30
|
+
'ValorServicos' => @request[:total],
|
31
|
+
'ValorDeducoes' => '0',
|
32
|
+
'ValorPis' => '0.00',
|
33
|
+
'ValorCofins' => '0.00',
|
34
|
+
'ValorInss' => '0.00',
|
35
|
+
'ValorIr' => '0.00',
|
36
|
+
'ValorCsll' => '0.00',
|
37
|
+
'ValorIss' => '0',
|
38
|
+
'Aliquota' => '5',
|
39
|
+
'DescontoIncondicionado' => '0.00'
|
40
|
+
},
|
41
|
+
'IssRetido' => '2',
|
42
|
+
'CodigoTributacaoMunicipio' => '791120000',
|
43
|
+
'Discriminacao' => @request[:description],
|
44
|
+
'CodigoMunicipio' => '0025300',
|
45
|
+
'ExigibilidadeISS' => '1',
|
46
|
+
'MunicipioIncidencia' => '0025300'
|
47
|
+
}, 'Prestador' => {
|
48
|
+
'IdentificacaoPrestador' => {
|
49
|
+
'CpfCnpj' => {
|
50
|
+
'Cnpj' => NfseGyn.configuration.cnpj
|
51
|
+
}, 'InscricaoMunicipal' => NfseGyn.configuration.inscricao_municipal
|
52
|
+
}
|
53
|
+
}, 'Tomador' => {
|
54
|
+
'IdentificacaoTomador' => {
|
55
|
+
'CpfCnpj' => {
|
56
|
+
(@request[:customer][:document_type]).to_s => (@request[:customer][:document_number]).to_s
|
57
|
+
}
|
58
|
+
},
|
59
|
+
'RazaoSocial' => @request[:customer][:name],
|
60
|
+
'Endereco' => {
|
61
|
+
'Endereco' => 'RUA DAS AMENDOEIRAS',
|
62
|
+
'Numero' => '30',
|
63
|
+
'Complemento' => 'LOTE 4',
|
64
|
+
'Bairro' => 'CENTRO',
|
65
|
+
'CodigoMunicipio' => '0025300',
|
66
|
+
'Uf' => 'GO',
|
67
|
+
'Cep' => '74823350'
|
68
|
+
}
|
69
|
+
}, 'OptanteSimplesNacional' => '2'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module NfseGyn
|
2
|
+
class MockGerarNfseResponse < NfseGyn::GerarNfse::Response
|
3
|
+
def initialize(request)
|
4
|
+
super(nil)
|
5
|
+
@request = request
|
6
|
+
end
|
7
|
+
|
8
|
+
def content
|
9
|
+
{
|
10
|
+
'ListaNfse' => {
|
11
|
+
'CompNfse' => {
|
12
|
+
'Nfse' => {
|
13
|
+
'InfNfse' => {
|
14
|
+
'Numero' => '370',
|
15
|
+
'CodigoVerificacao' => 'MB94-C3ZA',
|
16
|
+
'DataEmissao' => @request[:data_emissao],
|
17
|
+
'OutrasInformacoes' => 'OUTRAS INFORMACOES SOBRE O SERVICO.',
|
18
|
+
'ValoresNfse' => {
|
19
|
+
'BaseCalculo' => '0',
|
20
|
+
'Aliquota' => '5',
|
21
|
+
'ValorIss' => '0'
|
22
|
+
}, 'DeclaracaoPrestacaoServico' => {
|
23
|
+
'IdentificacaoRps' => {
|
24
|
+
'Numero' => '14',
|
25
|
+
'Serie' => 'UNICA',
|
26
|
+
'Tipo' => '1'
|
27
|
+
},
|
28
|
+
'DataEmissao' => @request[:data_emissao],
|
29
|
+
'Competencia' => @request[:data_emissao],
|
30
|
+
'Servico' => {
|
31
|
+
'Valores' => {
|
32
|
+
'ValorServicos' => @request[:total],
|
33
|
+
'ValorDeducoes' => '0',
|
34
|
+
'ValorPis' => '0.00',
|
35
|
+
'ValorCofins' => '0.00',
|
36
|
+
'ValorInss' => '0.00',
|
37
|
+
'ValorIr' => '0.00',
|
38
|
+
'ValorCsll' => '0.00',
|
39
|
+
'ValorIss' => '0',
|
40
|
+
'Aliquota' => '5',
|
41
|
+
'DescontoIncondicionado' => '0.00'
|
42
|
+
},
|
43
|
+
'IssRetido' => '2',
|
44
|
+
'CodigoTributacaoMunicipio' => '791120000',
|
45
|
+
'Discriminacao' => @request[:description],
|
46
|
+
'CodigoMunicipio' => '0025300',
|
47
|
+
'ExigibilidadeISS' => '1',
|
48
|
+
'MunicipioIncidencia' => '0025300'
|
49
|
+
}, 'Prestador' => {
|
50
|
+
'IdentificacaoPrestador' => {
|
51
|
+
'CpfCnpj' => {
|
52
|
+
'Cnpj' => NfseGyn.configuration.cnpj
|
53
|
+
}, 'InscricaoMunicipal' => NfseGyn.configuration.inscricao_municipal
|
54
|
+
}
|
55
|
+
}, 'Tomador' => {
|
56
|
+
'IdentificacaoTomador' => {
|
57
|
+
'CpfCnpj' => {
|
58
|
+
(@request[:customer][:document_type]).to_s => (@request[:customer][:document_number]).to_s
|
59
|
+
}
|
60
|
+
},
|
61
|
+
'RazaoSocial' => @request[:customer][:name],
|
62
|
+
'Endereco' => {
|
63
|
+
'Endereco' => 'RUA DAS AMENDOEIRAS',
|
64
|
+
'Numero' => '30',
|
65
|
+
'Complemento' => 'LOTE 4',
|
66
|
+
'Bairro' => 'CENTRO',
|
67
|
+
'CodigoMunicipio' => '0025300',
|
68
|
+
'Uf' => 'GO',
|
69
|
+
'Cep' => '74823350'
|
70
|
+
}
|
71
|
+
}, 'OptanteSimplesNacional' => '2'
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}, 'ListaMensagemRetorno' => {
|
77
|
+
'MensagemRetorno' => {
|
78
|
+
'Codigo' => 'L000',
|
79
|
+
'Mensagem' => 'NORMAL'
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/nfse_gyn/response.rb
CHANGED
data/lib/nfse_gyn/soap_client.rb
CHANGED
@@ -11,6 +11,7 @@ module NfseGyn
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def client
|
14
|
+
log = NfseGyn.configuration.log_level != :none
|
14
15
|
@client ||= Savon.client(
|
15
16
|
wsdl: NfseGyn.configuration.wsdl,
|
16
17
|
env_namespace: :soap,
|
@@ -21,8 +22,8 @@ module NfseGyn
|
|
21
22
|
ssl_cert_key_file: NfseGyn.configuration.cert_key_path,
|
22
23
|
ssl_ca_cert_file: NfseGyn.configuration.ca_cert_path,
|
23
24
|
ssl_cert_key_password: NfseGyn.configuration.cert_key_password,
|
24
|
-
log_level: NfseGyn.configuration.log_level,
|
25
|
-
log:
|
25
|
+
log_level: log ? NfseGyn.configuration.log_level : nil,
|
26
|
+
log: log,
|
26
27
|
open_timeout: 120,
|
27
28
|
read_timeout: 120
|
28
29
|
)
|
data/lib/nfse_gyn/version.rb
CHANGED
data/lib/nfse_gyn.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'active_model'
|
5
|
+
require 'active_support'
|
6
|
+
require 'active_support/core_ext'
|
5
7
|
|
6
8
|
require 'nfse_gyn/version'
|
7
9
|
require 'nfse_gyn/configuration'
|
@@ -10,6 +12,8 @@ require 'nfse_gyn/soap_client'
|
|
10
12
|
require 'nfse_gyn/response'
|
11
13
|
require 'nfse_gyn/gerar_nfse'
|
12
14
|
require 'nfse_gyn/consultar_nfse'
|
15
|
+
require 'nfse_gyn/mock_gerar_nfse_response'
|
16
|
+
require 'nfse_gyn/mock_consultar_nfse_response'
|
13
17
|
|
14
18
|
HTTPI.adapter = :net_http
|
15
19
|
|
data/nfse_gyn.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ['ramonvic@me.com']
|
10
10
|
|
11
11
|
spec.summary = 'Gem para realizar a geração de NFSE em Goiânia'
|
12
|
-
spec.homepage =
|
12
|
+
spec.homepage = 'https://github.com/ramonvic/nfse_gyn'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.metadata['homepage_uri'] = spec.homepage
|
@@ -19,11 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'activemodel',
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency '
|
22
|
+
spec.add_dependency 'activemodel', '~> 3.0'
|
23
|
+
spec.add_dependency 'activesupport', '~> 3.0'
|
24
|
+
spec.add_dependency 'savon', '~> 2.9'
|
25
|
+
spec.add_dependency 'signer', '~> 1.10'
|
25
26
|
|
26
|
-
spec.add_development_dependency 'bundler',
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
27
28
|
spec.add_development_dependency 'pry'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
29
30
|
spec.add_development_dependency 'rspec'
|
@@ -45,4 +45,30 @@ RSpec.describe NfseGyn::Configuration do
|
|
45
45
|
it { expect(NfseGyn.configuration.cert_key_password).to eq 'very-secure-encrypted-password' }
|
46
46
|
it { expect(NfseGyn.configuration.wsdl).to eq 'https://nfse.goiania.go.gov.br/ws/nfse.asmx?wsdl' }
|
47
47
|
end
|
48
|
+
|
49
|
+
describe '#from_h' do
|
50
|
+
let(:hash) do
|
51
|
+
{
|
52
|
+
test_mode: true,
|
53
|
+
cert_path: 'certicate.pem',
|
54
|
+
ca_cert_path: 'ca/certicate.pem',
|
55
|
+
cert_key_path: 'certicate/key.pem',
|
56
|
+
cert_key_password: 'updated-password'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
before do
|
61
|
+
NfseGyn.configuration.from_h(hash)
|
62
|
+
end
|
63
|
+
|
64
|
+
after do
|
65
|
+
NfseGyn.reset!
|
66
|
+
end
|
67
|
+
|
68
|
+
it { expect(NfseGyn.configuration.test_mode).to be_truthy }
|
69
|
+
it { expect(NfseGyn.configuration.cert_path).to eq 'certicate.pem' }
|
70
|
+
it { expect(NfseGyn.configuration.ca_cert_path).to eq 'ca/certicate.pem' }
|
71
|
+
it { expect(NfseGyn.configuration.cert_key_path).to eq 'certicate/key.pem' }
|
72
|
+
it { expect(NfseGyn.configuration.cert_key_password).to eq 'updated-password' }
|
73
|
+
end
|
48
74
|
end
|
data/spec/lib/gerar_nfse_spec.rb
CHANGED
@@ -19,16 +19,17 @@ RSpec.describe NfseGyn::GerarNfse do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#execute!' do
|
22
|
+
let(:response) { File.read(fixture_file_path('xmls/valid_gerar_nfse_response.xml'))}
|
22
23
|
let(:xml_payload) { File.read(fixture_file_path('xmls/valid_gerar_nfse_request.xml')) }
|
23
24
|
let(:request_payload) { "<ArquivoXML><![CDATA[#{xml_payload}]]></ArquivoXML>" }
|
24
25
|
|
25
26
|
before do
|
26
27
|
allow(subject).to receive(:to_xml).and_return(xml_payload)
|
27
|
-
savon.expects(:gerar_nfse).with(message: request_payload).returns(response)
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'valid request' do
|
31
|
-
|
31
|
+
|
32
|
+
before { savon.expects(:gerar_nfse).with(message: request_payload).returns(response) }
|
32
33
|
|
33
34
|
it 'returns a valid response' do
|
34
35
|
expect(subject.execute!).to be_successful
|
@@ -38,6 +39,8 @@ RSpec.describe NfseGyn::GerarNfse do
|
|
38
39
|
context 'invalid request' do
|
39
40
|
let(:response) { File.read(fixture_file_path('xmls/invalid_gerar_nfse_response.xml'))}
|
40
41
|
|
42
|
+
before { savon.expects(:gerar_nfse).with(message: request_payload).returns(response) }
|
43
|
+
|
41
44
|
it 'returns a invalid response' do
|
42
45
|
expect(subject.execute!).to_not be_successful
|
43
46
|
end
|
@@ -46,5 +49,18 @@ RSpec.describe NfseGyn::GerarNfse do
|
|
46
49
|
expect(subject.execute!.error_message).to eq('Para essa Inscrição Municipal/CNPJ já existe um RPS informado com o mesmo número, série e tipo.')
|
47
50
|
end
|
48
51
|
end
|
52
|
+
|
53
|
+
context 'when mock data' do
|
54
|
+
before do
|
55
|
+
NfseGyn.configuration.mock_mode = true
|
56
|
+
allow(NfseGyn::MockGerarNfseResponse).to receive(:new).and_return("mock response")
|
57
|
+
end
|
58
|
+
|
59
|
+
after { NfseGyn.configuration.mock_mode = false }
|
60
|
+
|
61
|
+
it 'should return a MockConsultarNfseResponse' do
|
62
|
+
expect(subject.execute!).to eq("mock response")
|
63
|
+
end
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|
@@ -40,7 +40,7 @@ RSpec.describe NfseGyn::GerarNfseXML do
|
|
40
40
|
describe '#certificate' do
|
41
41
|
context 'when has not certificate in configuration' do
|
42
42
|
it 'shoud certificate is nil' do
|
43
|
-
expect(subject.certificate).to be_nil
|
43
|
+
expect(subject.send(:certificate)).to be_nil
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -54,7 +54,7 @@ RSpec.describe NfseGyn::GerarNfseXML do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'shoud certificate not nil' do
|
57
|
-
expect(subject.certificate).to_not be_nil
|
57
|
+
expect(subject.send(:certificate)).to_not be_nil
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -62,7 +62,7 @@ RSpec.describe NfseGyn::GerarNfseXML do
|
|
62
62
|
describe '#private_key' do
|
63
63
|
context 'when has not private_key in configuration' do
|
64
64
|
it 'shoud private_key is nil' do
|
65
|
-
expect(subject.private_key).to be_nil
|
65
|
+
expect(subject.send(:private_key)).to be_nil
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -76,7 +76,7 @@ RSpec.describe NfseGyn::GerarNfseXML do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'shoud private_key not nil' do
|
79
|
-
expect(subject.private_key).to_not be_nil
|
79
|
+
expect(subject.send(:private_key)).to_not be_nil
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nfse_gyn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Vicente
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: savon
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +122,7 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
|
-
description:
|
125
|
+
description:
|
112
126
|
email:
|
113
127
|
- ramonvic@me.com
|
114
128
|
executables:
|
@@ -131,6 +145,8 @@ files:
|
|
131
145
|
- lib/nfse_gyn/consultar_nfse.rb
|
132
146
|
- lib/nfse_gyn/gerar_nfse.rb
|
133
147
|
- lib/nfse_gyn/gerar_nfse_xml.rb
|
148
|
+
- lib/nfse_gyn/mock_consultar_nfse_response.rb
|
149
|
+
- lib/nfse_gyn/mock_gerar_nfse_response.rb
|
134
150
|
- lib/nfse_gyn/response.rb
|
135
151
|
- lib/nfse_gyn/sanitizer.rb
|
136
152
|
- lib/nfse_gyn/soap_client.rb
|
@@ -149,14 +165,13 @@ files:
|
|
149
165
|
- spec/lib/gerar_nfse_spec.rb
|
150
166
|
- spec/lib/gerar_nfse_xml_spec.rb
|
151
167
|
- spec/lib/sanitizer_spec.rb
|
152
|
-
- spec/nfse_gyn_spec.rb
|
153
168
|
- spec/spec_helper.rb
|
154
169
|
homepage: https://github.com/ramonvic/nfse_gyn
|
155
170
|
licenses:
|
156
171
|
- MIT
|
157
172
|
metadata:
|
158
173
|
homepage_uri: https://github.com/ramonvic/nfse_gyn
|
159
|
-
post_install_message:
|
174
|
+
post_install_message:
|
160
175
|
rdoc_options: []
|
161
176
|
require_paths:
|
162
177
|
- lib
|
@@ -171,8 +186,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
186
|
- !ruby/object:Gem::Version
|
172
187
|
version: '0'
|
173
188
|
requirements: []
|
174
|
-
|
175
|
-
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 2.2.3
|
191
|
+
signing_key:
|
176
192
|
specification_version: 4
|
177
193
|
summary: Gem para realizar a geração de NFSE em Goiânia
|
178
194
|
test_files:
|
@@ -189,5 +205,4 @@ test_files:
|
|
189
205
|
- spec/lib/gerar_nfse_spec.rb
|
190
206
|
- spec/lib/gerar_nfse_xml_spec.rb
|
191
207
|
- spec/lib/sanitizer_spec.rb
|
192
|
-
- spec/nfse_gyn_spec.rb
|
193
208
|
- spec/spec_helper.rb
|