nfse_gyn 0.1.0
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +83 -0
- data/LICENSE.txt +21 -0
- data/README.md +113 -0
- data/Rakefile +12 -0
- data/bin/console +27 -0
- data/bin/setup +8 -0
- data/lib/nfse_gyn/configuration.rb +35 -0
- data/lib/nfse_gyn/consultar_nfse.rb +58 -0
- data/lib/nfse_gyn/gerar_nfse.rb +49 -0
- data/lib/nfse_gyn/gerar_nfse_xml.rb +120 -0
- data/lib/nfse_gyn/response.rb +31 -0
- data/lib/nfse_gyn/sanitizer.rb +17 -0
- data/lib/nfse_gyn/soap_client.rb +31 -0
- data/lib/nfse_gyn/version.rb +5 -0
- data/lib/nfse_gyn.rb +28 -0
- data/nfse_gyn.gemspec +30 -0
- data/spec/fixtures/ssl/cert.pem +17 -0
- data/spec/fixtures/ssl/key.pem +18 -0
- data/spec/fixtures/xmls/invalid_consultar_nfse_response.xml +21 -0
- data/spec/fixtures/xmls/invalid_gerar_nfse_response.xml +25 -0
- data/spec/fixtures/xmls/valid_consultar_nfse_request.xml +13 -0
- data/spec/fixtures/xmls/valid_consultar_nfse_response.xml +93 -0
- data/spec/fixtures/xmls/valid_gerar_nfse_request.xml +75 -0
- data/spec/fixtures/xmls/valid_gerar_nfse_response.xml +95 -0
- data/spec/lib/configuration_spec.rb +48 -0
- data/spec/lib/consultar_nfse_spec.rb +45 -0
- data/spec/lib/gerar_nfse_spec.rb +50 -0
- data/spec/lib/gerar_nfse_xml_spec.rb +145 -0
- data/spec/lib/sanitizer_spec.rb +15 -0
- data/spec/nfse_gyn_spec.rb +11 -0
- data/spec/spec_helper.rb +32 -0
- metadata +193 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'savon/mock/spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe NfseGyn::GerarNfseXML do
|
5
|
+
subject { described_class.new(invoice_info) }
|
6
|
+
|
7
|
+
let(:zipcode) { '74672680' }
|
8
|
+
let(:description) { 'Teste de RPS' }
|
9
|
+
let(:invoice_info) do
|
10
|
+
{
|
11
|
+
identification_number: '3033',
|
12
|
+
description: description,
|
13
|
+
data_emissao: '2024-01-11T23:33:22',
|
14
|
+
total: 100.10,
|
15
|
+
customer: {
|
16
|
+
document_type: 'Cnpj',
|
17
|
+
document_number: '98924674000187',
|
18
|
+
name: 'XPTO Tecnologia Ltda',
|
19
|
+
phone_number: '34051727',
|
20
|
+
email: 'customer@example.com',
|
21
|
+
address: {
|
22
|
+
street: 'Rua das Rosas',
|
23
|
+
number: '111',
|
24
|
+
complement: 'Sobre Loja',
|
25
|
+
neighborhood: 'Centro',
|
26
|
+
city_ibge_code: '0025300',
|
27
|
+
state_code: 'GO',
|
28
|
+
zipcode: zipcode
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#initialize' do
|
35
|
+
it 'initializes with invoice_info' do
|
36
|
+
expect(subject.instance_variable_get(:@invoice)).to eq(invoice_info)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#certificate' do
|
41
|
+
context 'when has not certificate in configuration' do
|
42
|
+
it 'shoud certificate is nil' do
|
43
|
+
expect(subject.certificate).to be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when a certificate exists in configuration' do
|
48
|
+
before do
|
49
|
+
NfseGyn.configuration.cert_path = fixture_file_path('ssl/cert.pem')
|
50
|
+
end
|
51
|
+
|
52
|
+
after do
|
53
|
+
NfseGyn.reset!
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'shoud certificate not nil' do
|
57
|
+
expect(subject.certificate).to_not be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#private_key' do
|
63
|
+
context 'when has not private_key in configuration' do
|
64
|
+
it 'shoud private_key is nil' do
|
65
|
+
expect(subject.private_key).to be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when a private_key exists in configuration' do
|
70
|
+
before do
|
71
|
+
NfseGyn.configuration.cert_key_path = fixture_file_path('ssl/key.pem')
|
72
|
+
end
|
73
|
+
|
74
|
+
after do
|
75
|
+
NfseGyn.reset!
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'shoud private_key not nil' do
|
79
|
+
expect(subject.private_key).to_not be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#to_xml' do
|
85
|
+
context 'when everything is fine' do
|
86
|
+
it 'contains correct identification number' do
|
87
|
+
expect(subject.to_xml).to include %(<Numero>3033</Numero>)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'contains correct description' do
|
91
|
+
expect(subject.to_xml).to include %(<Discriminacao>Teste de RPS)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'contains correct description' do
|
95
|
+
expect(subject.to_xml).to include %(<ValorServicos>100.1</ValorServicos>)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'contains correct provider information' do
|
99
|
+
expect(subject.to_xml).to include %(<Prestador><CpfCnpj><Cnpj>#{NfseGyn.configuration.cnpj}</Cnpj></CpfCnpj><InscricaoMunicipal>#{NfseGyn.configuration.inscricao_municipal}</InscricaoMunicipal></Prestador>)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'contains correct customer information' do
|
103
|
+
expect(subject.to_xml).to include %(<IdentificacaoTomador><CpfCnpj><Cnpj>98924674000187</Cnpj></CpfCnpj></IdentificacaoTomador>)
|
104
|
+
expect(subject.to_xml).to include %(<RazaoSocial>XPTO Tecnologia Ltda</RazaoSocial>)
|
105
|
+
expect(subject.to_xml).to include %(<Endereco><Endereco>Rua das Rosas</Endereco><Numero>111</Numero><Complemento>Sobre Loja</Complemento><Bairro>Centro</Bairro><CodigoMunicipio>0025300</CodigoMunicipio><Uf>GO</Uf><Cep>74672680</Cep></Endereco>)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when zipcode is wrong format' do
|
110
|
+
context 'when number is 05116-050' do
|
111
|
+
let(:zipcode) { '05116-050' }
|
112
|
+
|
113
|
+
it { expect(subject.to_xml).to include %(<Cep>05116050</Cep>) }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when description has especial characters' do
|
118
|
+
let(:description) { 'Descrição do Serviço' }
|
119
|
+
|
120
|
+
it { expect(subject.to_xml).to include %(<Discriminacao>Descricao do Servico) }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when has certificate to sign request' do
|
124
|
+
before do
|
125
|
+
NfseGyn.configuration.cert_path = fixture_file_path('ssl/cert.pem')
|
126
|
+
NfseGyn.configuration.cert_key_path = fixture_file_path('ssl/key.pem')
|
127
|
+
NfseGyn.configuration.cert_key_password = 'test'
|
128
|
+
end
|
129
|
+
|
130
|
+
after do
|
131
|
+
NfseGyn.reset!
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should include signature node' do
|
135
|
+
expect(subject.to_xml).to include('<Signature')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when has not certificate' do
|
140
|
+
it 'should not include signature node' do
|
141
|
+
expect(subject.to_xml).to_not include('<Signature')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe NfseGyn::Sanitizer do
|
4
|
+
describe '#clear' do
|
5
|
+
{
|
6
|
+
'Descrição do Servico com vários caracteres especiais.' => 'Descricao do Servico com varios caracteres especiais',
|
7
|
+
'Parque Amazônia,79 / Sala 313' => 'Parque Amazonia79 Sala 313'
|
8
|
+
}.each do |dirty, clean|
|
9
|
+
context "when #{dirty}" do
|
10
|
+
subject { described_class.new(dirty).clear }
|
11
|
+
it { is_expected.to eq clean }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nfse_gyn'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
def fixture_file_path(filename)
|
7
|
+
File.join(File.dirname(__FILE__), 'fixtures', filename)
|
8
|
+
end
|
9
|
+
|
10
|
+
Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before do
|
14
|
+
NfseGyn.configure do |nfse|
|
15
|
+
nfse.test_mode = true
|
16
|
+
nfse.cnpj = '46034125000133'
|
17
|
+
nfse.inscricao_municipal = '5671485'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
config.disable_monkey_patching!
|
22
|
+
|
23
|
+
config.profile_examples = 5
|
24
|
+
|
25
|
+
config.order = :random
|
26
|
+
|
27
|
+
Kernel.srand config.seed
|
28
|
+
|
29
|
+
config.expect_with :rspec do |c|
|
30
|
+
c.syntax = :expect
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nfse_gyn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ramon Vicente
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: savon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: signer
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- ramonvic@me.com
|
114
|
+
executables:
|
115
|
+
- console
|
116
|
+
- setup
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- lib/nfse_gyn.rb
|
130
|
+
- lib/nfse_gyn/configuration.rb
|
131
|
+
- lib/nfse_gyn/consultar_nfse.rb
|
132
|
+
- lib/nfse_gyn/gerar_nfse.rb
|
133
|
+
- lib/nfse_gyn/gerar_nfse_xml.rb
|
134
|
+
- lib/nfse_gyn/response.rb
|
135
|
+
- lib/nfse_gyn/sanitizer.rb
|
136
|
+
- lib/nfse_gyn/soap_client.rb
|
137
|
+
- lib/nfse_gyn/version.rb
|
138
|
+
- nfse_gyn.gemspec
|
139
|
+
- spec/fixtures/ssl/cert.pem
|
140
|
+
- spec/fixtures/ssl/key.pem
|
141
|
+
- spec/fixtures/xmls/invalid_consultar_nfse_response.xml
|
142
|
+
- spec/fixtures/xmls/invalid_gerar_nfse_response.xml
|
143
|
+
- spec/fixtures/xmls/valid_consultar_nfse_request.xml
|
144
|
+
- spec/fixtures/xmls/valid_consultar_nfse_response.xml
|
145
|
+
- spec/fixtures/xmls/valid_gerar_nfse_request.xml
|
146
|
+
- spec/fixtures/xmls/valid_gerar_nfse_response.xml
|
147
|
+
- spec/lib/configuration_spec.rb
|
148
|
+
- spec/lib/consultar_nfse_spec.rb
|
149
|
+
- spec/lib/gerar_nfse_spec.rb
|
150
|
+
- spec/lib/gerar_nfse_xml_spec.rb
|
151
|
+
- spec/lib/sanitizer_spec.rb
|
152
|
+
- spec/nfse_gyn_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
homepage: https://github.com/ramonvic/nfse_gyn
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata:
|
158
|
+
homepage_uri: https://github.com/ramonvic/nfse_gyn
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubygems_version: 3.4.10
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Gem para realizar a geração de NFSE em Goiânia
|
178
|
+
test_files:
|
179
|
+
- spec/fixtures/ssl/cert.pem
|
180
|
+
- spec/fixtures/ssl/key.pem
|
181
|
+
- spec/fixtures/xmls/invalid_consultar_nfse_response.xml
|
182
|
+
- spec/fixtures/xmls/invalid_gerar_nfse_response.xml
|
183
|
+
- spec/fixtures/xmls/valid_consultar_nfse_request.xml
|
184
|
+
- spec/fixtures/xmls/valid_consultar_nfse_response.xml
|
185
|
+
- spec/fixtures/xmls/valid_gerar_nfse_request.xml
|
186
|
+
- spec/fixtures/xmls/valid_gerar_nfse_response.xml
|
187
|
+
- spec/lib/configuration_spec.rb
|
188
|
+
- spec/lib/consultar_nfse_spec.rb
|
189
|
+
- spec/lib/gerar_nfse_spec.rb
|
190
|
+
- spec/lib/gerar_nfse_xml_spec.rb
|
191
|
+
- spec/lib/sanitizer_spec.rb
|
192
|
+
- spec/nfse_gyn_spec.rb
|
193
|
+
- spec/spec_helper.rb
|