kono_epp_client 0.1.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +29 -0
- data/Makefile +13 -0
- data/README.md +20 -3
- data/kono_epp_client.gemspec +4 -1
- data/lib/kono_epp_client/VERSION +1 -1
- data/lib/kono_epp_client/commands/check_contacts.rb +19 -0
- data/lib/{epp/epp_command/kono_epp_check_domains.rb → kono_epp_client/commands/check_domains.rb} +3 -1
- data/lib/kono_epp_client/commands/command.rb +15 -0
- data/lib/kono_epp_client/commands/create_contact.rb +89 -0
- data/lib/kono_epp_client/commands/create_domain.rb +56 -0
- data/lib/kono_epp_client/commands/delete_contact.rb +17 -0
- data/lib/kono_epp_client/commands/delete_domain.rb +16 -0
- data/lib/kono_epp_client/commands/hello.rb +15 -0
- data/lib/kono_epp_client/commands/info_contact.rb +17 -0
- data/lib/kono_epp_client/commands/info_domain.rb +16 -0
- data/lib/kono_epp_client/commands/login.rb +84 -0
- data/lib/kono_epp_client/commands/logout.rb +12 -0
- data/lib/kono_epp_client/commands/poll.rb +18 -0
- data/lib/kono_epp_client/commands/transfer_domain.rb +38 -0
- data/lib/kono_epp_client/commands/update_contact.rb +116 -0
- data/lib/kono_epp_client/commands/update_domain.rb +117 -0
- data/lib/kono_epp_client/dns_sec/add.rb +13 -0
- data/lib/kono_epp_client/dns_sec/ds_data.rb +65 -0
- data/lib/kono_epp_client/dns_sec/rem.rb +14 -0
- data/lib/kono_epp_client/dns_sec/rem_all.rb +10 -0
- data/lib/kono_epp_client/exceptions/error_response.rb +19 -0
- data/lib/kono_epp_client/exceptions.rb +15 -0
- data/lib/kono_epp_client/requires_parameters.rb +16 -0
- data/lib/{epp → kono_epp_client}/server.rb +63 -55
- data/lib/kono_epp_client.rb +4 -16
- data/spec/eager_load_spec.rb +6 -0
- data/spec/factories/ds_data.rb +12 -0
- data/spec/fixtures/dns_sec/add.xml +14 -0
- data/spec/fixtures/dns_sec/ds_data.xml +6 -0
- data/spec/fixtures/dns_sec/rem.xml +14 -0
- data/spec/fixtures/dns_sec/rem_all.xml +3 -0
- data/spec/fixtures/login_response.xml +23 -0
- data/spec/fixtures/login_response_for_dnssec.xml +25 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/create_domain/_create_with_ds_data_build_extensions.xml.snap +39 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_login.xml.snap +7 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_extensions_with_value_xml.xml.snap +14 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_lang_with_value_xml.xml.snap +11 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_new_password_with_value_xml.xml.snap +9 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_services_with_value_xml.xml.snap +12 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_version_with_value_xml.xml.snap +11 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_with_id_and_password_login.xml.snap +10 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/update_domain/_update_DnsSec_build_extensions.xml.snap +30 -0
- data/spec/{epp/epp_command/kono_epp_check_contacts_spec.rb → lib/commands/check_contacts_spec.rb} +1 -1
- data/spec/{epp/epp_command/kono_epp_check_domains_spec.rb → lib/commands/check_domains_spec.rb} +1 -1
- data/spec/{epp/kono_epp_command_spec.rb → lib/commands/command_spec.rb} +2 -2
- data/spec/lib/commands/create_domain_spec.rb +50 -0
- data/spec/lib/commands/login_spec.rb +87 -0
- data/spec/{epp/epp_command/kono_epp_transfer_domain_spec.rb → lib/commands/transfer_domain_spec.rb} +1 -1
- data/spec/{epp/epp_command/kono_epp_update_domain_spec.rb → lib/commands/update_domain_spec.rb} +20 -4
- data/spec/lib/dns_sec/add_spec.rb +14 -0
- data/spec/lib/dns_sec/ds_data_spec.rb +43 -0
- data/spec/lib/dns_sec/rem_all_spec.rb +11 -0
- data/spec/lib/dns_sec/rem_spec.rb +14 -0
- data/spec/lib/server_spec.rb +304 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/support/context.rb +1 -1
- data/spec/support/factory_bot.rb +8 -0
- data/spec/support/fixtures.rb +16 -0
- data/spec/support/matchers.rb +14 -0
- data/spec/support/parametric.rb +1 -0
- data/spec/support/snapshot.rb +12 -2
- metadata +157 -60
- data/lib/epp/epp_command/check_contacts.rb +0 -17
- data/lib/epp/epp_command/create_contact.rb +0 -87
- data/lib/epp/epp_command/create_domain.rb +0 -44
- data/lib/epp/epp_command/delete_contact.rb +0 -15
- data/lib/epp/epp_command/delete_domain.rb +0 -14
- data/lib/epp/epp_command/hello.rb +0 -13
- data/lib/epp/epp_command/info_contact.rb +0 -15
- data/lib/epp/epp_command/info_domain.rb +0 -14
- data/lib/epp/epp_command/login.rb +0 -79
- data/lib/epp/epp_command/logout.rb +0 -10
- data/lib/epp/epp_command/poll.rb +0 -16
- data/lib/epp/epp_command/transfer_domain.rb +0 -36
- data/lib/epp/epp_command/update_contact.rb +0 -115
- data/lib/epp/epp_command/update_domain.rb +0 -104
- data/lib/epp/epp_command.rb +0 -15
- data/lib/epp/exceptions.rb +0 -28
- data/lib/epp/transport/tcp.rb +0 -93
- data/lib/require_parameters.rb +0 -14
- data/spec/epp/epp_command/kono_epp_create_domain_spec.rb +0 -37
- data/spec/epp/server_spec.rb +0 -69
- /data/lib/{epp/transport/http.rb → kono_epp_client/transport/http_transport.rb} +0 -0
- /data/lib/{epp → kono_epp_client}/transport.rb +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_check_contacts → kono_epp_client/commands/check_contacts}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_check_domains → kono_epp_client/commands/check_domains}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_create_domain → kono_epp_client/commands/create_domain}/_create.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_transfer_domain → kono_epp_client/commands/transfer_domain}/_con_extension_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_transfer_domain → kono_epp_client/commands/transfer_domain}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_restore_esiste_l'estensione_di_restore.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_auth_info_cambia_AUTH_INFO.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_auth_info_con_nuovo_registrant_cambia_REGISTRANT.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_contacts_cambia_ADMIN_TECH.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_nameservers_aggiunge_e_rimuove_ns.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_status_cambia_status.xml.snap +0 -0
@@ -0,0 +1,304 @@
|
|
1
|
+
RSpec.describe KonoEppClient::Server do
|
2
|
+
|
3
|
+
let(:params) {
|
4
|
+
{
|
5
|
+
tag: "abc",
|
6
|
+
password: "123123",
|
7
|
+
server: "epp.pubtest.nic.it"
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:instance) { described_class.new(params) }
|
12
|
+
|
13
|
+
##
|
14
|
+
# Impostazione per eseguire inviare comandi di login con estensione DNSSEC
|
15
|
+
shared_context "dnssec activation" do
|
16
|
+
let(:params) {
|
17
|
+
super().merge(enable_dns_sec: true)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Forza l'istanza come se avessi avuto conferma di connessione tramite DNSSEC
|
23
|
+
shared_context "dnssec activated" do
|
24
|
+
let(:instance) {
|
25
|
+
super().tap { |c| c.instance_variable_set(:@dns_sec_enabled, true) }
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "initialization" do
|
30
|
+
|
31
|
+
it "base" do
|
32
|
+
expect(instance).to have_attributes(
|
33
|
+
**params,
|
34
|
+
port: 700,
|
35
|
+
lang: "en",
|
36
|
+
services: ["urn:ietf:params:xml:ns:domain-1.0", "urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:host-1.0"],
|
37
|
+
extensions: [],
|
38
|
+
version: "1.0",
|
39
|
+
transport: :http,
|
40
|
+
transport_options: {},
|
41
|
+
timeout: 30,
|
42
|
+
ssl_version: :TLSv1
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
it_behaves_like "dnssec activation" do
|
47
|
+
|
48
|
+
it { expect(instance).to have_attributes(
|
49
|
+
extensions: include("urn:ietf:params:xml:ns:secDNS-1.1",
|
50
|
+
"http://www.nic.it/ITNIC-EPP/extsecDNS-1.0"),
|
51
|
+
dns_sec_enabled: false # questo viene abilitato rispetto alla risposta del NIC
|
52
|
+
)
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#open_connection" do
|
61
|
+
|
62
|
+
let(:params) {
|
63
|
+
super().merge(
|
64
|
+
transport: :http,
|
65
|
+
)
|
66
|
+
}
|
67
|
+
|
68
|
+
it "default transport" do
|
69
|
+
|
70
|
+
double = instance_double(KonoEppClient::Transport::HttpTransport)
|
71
|
+
|
72
|
+
expect(KonoEppClient::Transport::HttpTransport).to receive(:new).with(
|
73
|
+
params[:server],
|
74
|
+
700, ssl_version: :TLSv1, cookie_file: "abc.cookies.pstore").and_return(double)
|
75
|
+
|
76
|
+
expect { instance.open_connection }.to change { instance.instance_variable_get(:@connection) }.
|
77
|
+
to(double)
|
78
|
+
end
|
79
|
+
|
80
|
+
context "transport http" do
|
81
|
+
|
82
|
+
let(:params) {
|
83
|
+
super().merge(
|
84
|
+
transport_options: {cookie_file: "file_to_coockies"},
|
85
|
+
)
|
86
|
+
}
|
87
|
+
|
88
|
+
it "use http transport" do
|
89
|
+
double = instance_double(KonoEppClient::Transport::HttpTransport)
|
90
|
+
|
91
|
+
expect(KonoEppClient::Transport::HttpTransport).to receive(:new).with(
|
92
|
+
params[:server],
|
93
|
+
700, ssl_version: :TLSv1, cookie_file: "file_to_coockies").and_return(double)
|
94
|
+
|
95
|
+
expect { instance.open_connection }.to change { instance.instance_variable_get(:@connection) }.
|
96
|
+
to(double)
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#login" do
|
105
|
+
|
106
|
+
it {
|
107
|
+
expect(instance).to receive(:send_command) do |command|
|
108
|
+
expect(command.to_s).to have_tag("command>login") do
|
109
|
+
with_tag("options>version", text: "1.0")
|
110
|
+
with_tag("options>lang", text: "en")
|
111
|
+
instance.services.each do |srv|
|
112
|
+
with_tag("svcs>objuri", text: srv)
|
113
|
+
end
|
114
|
+
without_tag("svcs>svcextension")
|
115
|
+
end
|
116
|
+
Nokogiri::XML(file_fixture("login_response.xml").read) # Si aspetta un XML di risposta
|
117
|
+
end
|
118
|
+
|
119
|
+
instance.login
|
120
|
+
}
|
121
|
+
|
122
|
+
context "with extensions" do
|
123
|
+
let(:params) {
|
124
|
+
super().merge(extensions: ["https://nome.estensione", "altra:estensione"])
|
125
|
+
}
|
126
|
+
|
127
|
+
it {
|
128
|
+
expect(instance).to receive(:send_command) do |command|
|
129
|
+
expect(command.to_s).to have_tag("command>login>svcs>svcextension") do
|
130
|
+
with_tag("exturi", text: "https://nome.estensione")
|
131
|
+
with_tag("exturi", text: "altra:estensione")
|
132
|
+
end
|
133
|
+
Nokogiri::XML(file_fixture("login_response.xml").read) # Si aspetta un XML di risposta
|
134
|
+
end
|
135
|
+
|
136
|
+
instance.login
|
137
|
+
|
138
|
+
}
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
it_behaves_like "dnssec activation" do
|
143
|
+
|
144
|
+
it "requested" do
|
145
|
+
expect(instance).to receive(:send_command) do |command|
|
146
|
+
expect(command.to_s).to have_tag("command>login>svcs>svcextension") do
|
147
|
+
with_tag("exturi", text: "http://www.nic.it/ITNIC-EPP/extsecDNS-1.0")
|
148
|
+
with_tag("exturi", text: "urn:ietf:params:xml:ns:secDNS-1.1")
|
149
|
+
end
|
150
|
+
Nokogiri::XML(file_fixture("login_response_for_dnssec.xml").read) # Si aspetta un XML di risposta
|
151
|
+
end
|
152
|
+
|
153
|
+
instance.login
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
it "with response" do
|
158
|
+
allow(instance).to receive(:send_request)
|
159
|
+
.and_return(file_fixture("login_response_for_dnssec.xml").read)
|
160
|
+
|
161
|
+
expect {
|
162
|
+
instance.login
|
163
|
+
expect(instance).to be_dns_sec_enabled
|
164
|
+
}.to change(instance, :dns_sec_enabled).to(true)
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
it "response for Registrar not accredited" do
|
169
|
+
allow(instance).to receive(:send_request)
|
170
|
+
.and_return(file_fixture("login_response.xml").read)
|
171
|
+
|
172
|
+
expect {
|
173
|
+
instance.login
|
174
|
+
expect(instance).not_to be_dns_sec_enabled
|
175
|
+
}.not_to change(instance, :dns_sec_enabled)
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "#create_domain" do
|
183
|
+
|
184
|
+
let(:ds_data) {
|
185
|
+
create(:ds_data)
|
186
|
+
}
|
187
|
+
|
188
|
+
it {
|
189
|
+
expect(instance).to receive(:send_command) do |command|
|
190
|
+
expect(command.to_s).to have_xpath("//domain:create//domain:name[text()='architest.it']", {"domain" => "urn:ietf:params:xml:ns:domain-1.0"})
|
191
|
+
expect(command.to_s).not_to have_xpath("//extension//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
192
|
+
end
|
193
|
+
|
194
|
+
instance.create_domain(name: 'architest.it', nameservers: [])
|
195
|
+
|
196
|
+
}
|
197
|
+
|
198
|
+
it "impostando i dati del dnssec ma senza aver avuto conferma da NIC di poterlo usare" do
|
199
|
+
expect(instance).to receive(:send_command) do |command|
|
200
|
+
expect(command.to_s).not_to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
201
|
+
end
|
202
|
+
|
203
|
+
instance.create_domain(name: 'architest.it', nameservers: [], dns_sec_data: [ds_data])
|
204
|
+
end
|
205
|
+
|
206
|
+
it_behaves_like "dnssec activated" do
|
207
|
+
|
208
|
+
it "senza assegnare dnssec data non succede nulla" do
|
209
|
+
expect(instance).to receive(:send_command) do |command|
|
210
|
+
expect(command.to_s).not_to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
211
|
+
end
|
212
|
+
|
213
|
+
instance.create_domain(name: 'architest.it', nameservers: [])
|
214
|
+
end
|
215
|
+
|
216
|
+
it "assegnando dei valori" do
|
217
|
+
expect(instance).to receive(:send_command) do |command|
|
218
|
+
expect(command.to_s).to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
219
|
+
expect(command.to_s).to have_xpath(
|
220
|
+
"//secDNS:keyTag[text()='123']",
|
221
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
222
|
+
)
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
instance.create_domain(name: 'architest.it', nameservers: [], dns_sec_data: [ds_data])
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#update_domain" do
|
234
|
+
|
235
|
+
let(:ds_data_a) { create(:ds_data) }
|
236
|
+
let(:ds_data_b) { create(:ds_data) }
|
237
|
+
|
238
|
+
it {
|
239
|
+
expect(instance).to receive(:send_command) do |command|
|
240
|
+
expect(command.to_s).to have_xpath("//domain:update//domain:name[text()='architest.it']", {"xmlns:domain" => "urn:ietf:params:xml:ns:domain-1.0"})
|
241
|
+
expect(command.to_s).not_to have_xpath("//extension//secDNS:update", {"xmlns:secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
242
|
+
end
|
243
|
+
|
244
|
+
instance.update_domain(name: 'architest.it')
|
245
|
+
}
|
246
|
+
|
247
|
+
it "impostando i dati del dnssec ma senza aver avuto conferma da NIC di poterlo usare" do
|
248
|
+
expect(instance).to receive(:send_command) do |command|
|
249
|
+
expect(command.to_s).not_to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
250
|
+
end
|
251
|
+
|
252
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [KonoEppClient::DnsSec::Add.new(ds_data_a)])
|
253
|
+
end
|
254
|
+
|
255
|
+
it_behaves_like "dnssec activated" do
|
256
|
+
|
257
|
+
it "senza assegnare dnssec data non succede nulla" do
|
258
|
+
expect(instance).to receive(:send_command) do |command|
|
259
|
+
expect(command.to_s).not_to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
260
|
+
end
|
261
|
+
|
262
|
+
instance.update_domain(name: 'architest.it')
|
263
|
+
end
|
264
|
+
|
265
|
+
it "assegnando dei valori" do
|
266
|
+
expect(instance).to receive(:send_command) do |command|
|
267
|
+
expect(command.to_s).to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
268
|
+
|
269
|
+
expect(command.to_s).to have_xpath(
|
270
|
+
"//secDNS:update//secDNS:add//secDNS:dsData//secDNS:keyTag[text()='#{ds_data_a.key_tag}']",
|
271
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
272
|
+
)
|
273
|
+
expect(command.to_s).to have_xpath(
|
274
|
+
"//secDNS:update//secDNS:rem//secDNS:dsData//secDNS:keyTag[text()='#{ds_data_b.key_tag}']",
|
275
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
279
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [
|
280
|
+
KonoEppClient::DnsSec::Add.new(ds_data_a),
|
281
|
+
KonoEppClient::DnsSec::Rem.new(ds_data_b)
|
282
|
+
])
|
283
|
+
end
|
284
|
+
|
285
|
+
it "cancello tutti i ds_data" do
|
286
|
+
expect(instance).to receive(:send_command) do |command|
|
287
|
+
expect(command.to_s).to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
288
|
+
|
289
|
+
expect(command.to_s).to have_xpath(
|
290
|
+
"//secDNS:update//secDNS:rem//secDNS:all[text()='true']",
|
291
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [
|
296
|
+
KonoEppClient::DnsSec::RemAll.new
|
297
|
+
])
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,13 @@ Bundler.setup
|
|
3
3
|
|
4
4
|
require 'simplecov'
|
5
5
|
SimpleCov.start do
|
6
|
-
|
7
|
-
|
6
|
+
enable_coverage :branch
|
7
|
+
enable_coverage_for_eval
|
8
|
+
add_group "Commands","lib/kono_epp_client/commands"
|
9
|
+
add_filter "spec"
|
8
10
|
|
11
|
+
end
|
12
|
+
require 'debug'
|
9
13
|
require 'kono_epp_client' # and any other gems you need
|
10
14
|
|
11
15
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
data/spec/support/context.rb
CHANGED
@@ -9,7 +9,7 @@ RSpec.shared_context "like epp command" do
|
|
9
9
|
}
|
10
10
|
let(:rendered) {
|
11
11
|
x = Nokogiri::XML(raw_rendered_content)
|
12
|
-
x.remove_namespaces! #
|
12
|
+
x.remove_namespaces! # La ricerca con namespace deve essere fatta con have_xpath e il passaggio di namespace
|
13
13
|
x
|
14
14
|
}
|
15
15
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module FixturesReader
|
2
|
+
def file_fixture(filename)
|
3
|
+
fixuture_path = File.expand_path('../fixtures', File.dirname(__FILE__))
|
4
|
+
File.open("#{fixuture_path}/#{filename}", 'r')
|
5
|
+
end
|
6
|
+
|
7
|
+
##
|
8
|
+
# Stessa cosa del file_fixture ma elimina tutti gli spazi dal file xml
|
9
|
+
def xml_fixture(filename)
|
10
|
+
file_fixture(filename).read.gsub(/[[:space:]]/, '')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include FixturesReader
|
16
|
+
end
|
data/spec/support/matchers.rb
CHANGED
@@ -3,4 +3,18 @@ require 'rspec-html-matchers'
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
|
5
5
|
config.include RSpecHtmlMatchers
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec::Matchers.define :have_xpath do |xpath, *opts|
|
9
|
+
match do |str|
|
10
|
+
Nokogiri::XML(str).xpath(xpath, *opts).any?
|
11
|
+
end
|
12
|
+
|
13
|
+
failure_message do |str|
|
14
|
+
"Expected xpath #{xpath.inspect} to match in:\n" + Nokogiri::XML(str).to_xml(indent: 2)
|
15
|
+
end
|
16
|
+
|
17
|
+
failure_message_when_negated do |str|
|
18
|
+
"Expected xpath #{xpath.inspect} not to match in:\n" + Nokogiri::XML(str).to_xml(indent: 2)
|
19
|
+
end
|
6
20
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec-parameterized'
|
data/spec/support/snapshot.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
require "rspec/snapshot"
|
2
2
|
require "active_support/core_ext/string"
|
3
|
+
|
4
|
+
|
5
|
+
def first_parent_example_group(metadata)
|
6
|
+
parent = metadata[:parent_example_group] || metadata[:example_group]
|
7
|
+
return metadata if parent.nil?
|
8
|
+
first_parent_example_group(parent)
|
9
|
+
end
|
10
|
+
|
11
|
+
|
3
12
|
RSpec.configure do |config|
|
4
13
|
|
5
14
|
config.snapshot_dir = "spec/fixtures/snapshots"
|
@@ -7,8 +16,9 @@ RSpec.configure do |config|
|
|
7
16
|
config.after(:each, snapshot: true) do |example|
|
8
17
|
extension=nil
|
9
18
|
extension = ".#{example.metadata[:snapshot]}" unless example.metadata[:snapshot] === true
|
10
|
-
|
11
|
-
|
19
|
+
described_class = first_parent_example_group(example.metadata)[:described_class]
|
20
|
+
class_name = described_class.name.underscore
|
21
|
+
test_name = example.metadata[:full_description].gsub(described_class.name, "").tr(" ", "_")
|
12
22
|
raise "component snapshot has no content" if raw_rendered_content.nil? or raw_rendered_content.empty?
|
13
23
|
str_content = raw_rendered_content
|
14
24
|
if extension == ".xml"
|