kono_epp_client 0.0.2 → 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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +2 -0
  3. data/lib/epp/epp_command/check_contacts.rb +17 -0
  4. data/lib/epp/epp_command/create_contact.rb +87 -0
  5. data/lib/epp/epp_command/create_domain.rb +44 -0
  6. data/lib/epp/epp_command/delete_contact.rb +15 -0
  7. data/lib/epp/epp_command/delete_domain.rb +14 -0
  8. data/lib/epp/epp_command/hello.rb +13 -0
  9. data/lib/epp/epp_command/info_contact.rb +15 -0
  10. data/lib/epp/epp_command/info_domain.rb +14 -0
  11. data/lib/epp/epp_command/kono_epp_check_domains.rb +18 -0
  12. data/lib/epp/epp_command/login.rb +79 -0
  13. data/lib/epp/epp_command/logout.rb +10 -0
  14. data/lib/epp/epp_command/poll.rb +16 -0
  15. data/lib/epp/epp_command/transfer_domain.rb +36 -0
  16. data/lib/epp/epp_command/update_contact.rb +115 -0
  17. data/lib/epp/epp_command/update_domain.rb +104 -0
  18. data/lib/epp/epp_command.rb +15 -0
  19. data/lib/epp/exceptions.rb +28 -0
  20. data/lib/epp/server.rb +295 -0
  21. data/lib/epp/transport/http.rb +71 -0
  22. data/lib/epp/transport/tcp.rb +93 -0
  23. data/lib/epp/transport.rb +13 -0
  24. data/lib/kono_epp_client.rb +5 -14
  25. data/lib/require_parameters.rb +14 -0
  26. data/spec/epp/epp_command/kono_epp_check_contacts_spec.rb +25 -0
  27. data/spec/epp/epp_command/kono_epp_check_domains_spec.rb +16 -0
  28. data/spec/epp/epp_command/kono_epp_create_domain_spec.rb +37 -0
  29. data/spec/epp/epp_command/kono_epp_transfer_domain_spec.rb +33 -0
  30. data/spec/epp/epp_command/kono_epp_update_domain_spec.rb +125 -0
  31. data/spec/epp/kono_epp_command_spec.rb +16 -0
  32. data/spec/fixtures/snapshots/kono_epp_check_contacts/_construct.xml.snap +13 -0
  33. data/spec/fixtures/snapshots/kono_epp_check_domains/_construct.xml.snap +11 -0
  34. data/spec/fixtures/snapshots/kono_epp_create_domain/_create.xml.snap +29 -0
  35. data/spec/fixtures/snapshots/kono_epp_transfer_domain/_con_extension_construct.xml.snap +23 -0
  36. data/spec/fixtures/snapshots/kono_epp_transfer_domain/_construct.xml.snap +13 -0
  37. data/spec/fixtures/snapshots/kono_epp_update_domain/_restore_esiste_l'estensione_di_restore.xml.snap +15 -0
  38. data/spec/fixtures/snapshots/kono_epp_update_domain/_update_auth_info_cambia_AUTH_INFO.xml.snap +15 -0
  39. data/spec/fixtures/snapshots/kono_epp_update_domain/_update_auth_info_con_nuovo_registrant_cambia_REGISTRANT.xml.snap +16 -0
  40. data/spec/fixtures/snapshots/kono_epp_update_domain/_update_contacts_cambia_ADMIN_TECH.xml.snap +18 -0
  41. data/spec/fixtures/snapshots/kono_epp_update_domain/_update_nameservers_aggiunge_e_rimuove_ns.xml.snap +28 -0
  42. data/spec/fixtures/snapshots/kono_epp_update_domain/_update_status_cambia_status.xml.snap +16 -0
  43. data/spec/spec_helper.rb +111 -0
  44. data/spec/support/context.rb +15 -0
  45. data/spec/support/matchers.rb +6 -0
  46. data/spec/support/snapshot.rb +20 -0
  47. metadata +157 -6
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe KonoEppUpdateDomain do
4
+
5
+ let(:options) do
6
+ {
7
+ name: 'example.com',
8
+ # add_nameservers: [['ns1.example.com', '192.168.1.1']],
9
+ # add_admin: 'admin_contact',
10
+ # add_tech: 'tech_contact',
11
+ # remove_nameservers: ['ns2.example.com'],
12
+ # remove_admin: 'admin_contact_to_remove',
13
+ # remove_tech: 'tech_contact_to_remove',
14
+ # auth_info: 'my_auth_info',
15
+ # registrant: 'new_registrant'
16
+ }
17
+ end
18
+
19
+ include_context "like epp command"
20
+
21
+ let(:instance) {
22
+ KonoEppUpdateDomain.new(options)
23
+ }
24
+
25
+ it "contiene il nome del dominio" do
26
+ expect(rendered.to_s).to have_tag("update>name", text: options[:name])
27
+ end
28
+
29
+ context "update nameservers" do
30
+ let(:options) {
31
+ super().merge({
32
+ add_nameservers: [
33
+ ['ns1.example.com', '192.168.1.1'],
34
+ ['ns3.example.com']
35
+ ],
36
+ remove_nameservers: ['ns2.example.com'],
37
+ })
38
+ }
39
+ it "aggiunge e rimuove ns", snapshot: 'xml' do
40
+ expect(rendered.to_s.downcase).to have_tag("update>add>ns") do
41
+ with_tag("hostattr") do
42
+ with_tag("hostname", text: 'ns1.example.com')
43
+ with_tag("hostaddr", text: '192.168.1.1')
44
+ end
45
+ end
46
+ expect(rendered.to_s.downcase).to have_tag("update>add>ns") do
47
+ with_tag("hostattr") do
48
+ with_tag("hostname", text: 'ns3.example.com')
49
+ without_tag("hostaddr",text:"")
50
+ end
51
+ end
52
+ expect(rendered.to_s.downcase).to have_tag("update>rem>ns") do
53
+ with_tag("hostattr") do
54
+ with_tag("hostname", text: 'ns2.example.com')
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ context "update contacts", snapshot: 'xml' do
61
+ let(:options) {
62
+ super().merge({
63
+ add_admin: "AAA1",
64
+ add_tech: "TTT1",
65
+ remove_admin: "AAA2",
66
+ remove_tech: "TTT2"
67
+ })
68
+ }
69
+ it "cambia ADMIN_TECH", snapshot: 'xml' do
70
+ expect(rendered.to_s.downcase).to have_tag("update>add>contact", with: {type: "admin"}, text: options[:add_admin].downcase)
71
+ expect(rendered.to_s.downcase).to have_tag("update>rem>contact", with: {type: "admin"}, text: options[:remove_admin].downcase)
72
+ expect(rendered.to_s.downcase).to have_tag("update>add>contact", with: {type: "tech"}, text: options[:add_tech].downcase)
73
+ expect(rendered.to_s.downcase).to have_tag("update>rem>contact", with: {type: "tech"}, text: options[:remove_tech].downcase)
74
+ end
75
+ end
76
+ context "update status" do
77
+ let(:options) {
78
+ super().merge({
79
+ add_status: "clientTransferProhibited",
80
+ remove_status: "clientHold",
81
+ })
82
+ }
83
+ it "cambia status", snapshot: 'xml' do
84
+ expect(rendered.to_s.downcase).to have_tag("update>add>status", with: {s: options[:add_status].downcase})
85
+ expect(rendered.to_s.downcase).to have_tag("update>rem>status", with: {s: options[:remove_status].downcase})
86
+ end
87
+ end
88
+
89
+ context "restore" do
90
+ let(:options) {
91
+ super().merge({
92
+ restore: true
93
+ })
94
+ }
95
+ it "esiste l'estensione di restore",snapshot: 'xml' do
96
+ expect(rendered.to_s.downcase).to have_tag("extension>update>restore", with: {op: "request"})
97
+ end
98
+ end
99
+
100
+ context "update auth_info" do
101
+ let(:options) {
102
+ super().merge({
103
+ auth_info: "AUTH12-!DSRTG"
104
+ })
105
+ }
106
+ it "cambia AUTH_INFO", snapshot: "xml" do
107
+ expect(rendered.to_s.downcase).to have_tag("update>chg") do
108
+ with_tag("authinfo>pw", text: options[:auth_info].downcase)
109
+ without_tag("registrant")
110
+ end
111
+ end
112
+
113
+ context "con nuovo registrant" do
114
+ let(:options) {
115
+ super().merge({
116
+ registrant: "R0001"
117
+ })
118
+ }
119
+ it "cambia REGISTRANT", snapshot: "xml" do
120
+ expect(rendered.to_s.downcase).to have_tag("update>chg>registrant", text: options[:registrant].downcase)
121
+ end
122
+ end
123
+ end
124
+
125
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require 'rexml/document'
3
+
4
+ RSpec.describe KonoEppCommand do
5
+ it 'generates a valid XML document with the expected structure' do
6
+ xml_document = KonoEppCommand.new
7
+ expect(xml_document).to be_a(REXML::Document)
8
+ expect(xml_document.to_s).to include("xsi:schemaLocation='urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd'")
9
+ expect(xml_document.to_s).to include("xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'")
10
+ expect(xml_document.to_s).to have_tag("epp",with:{
11
+ xmlns:"urn:ietf:params:xml:ns:epp-1.0"
12
+ }) do
13
+ have_tag("command",count:1)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <check>
5
+ <contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
6
+ <contact:id>mm001</contact:id>
7
+ <contact:id>mb001</contact:id>
8
+ <contact:id>cl001</contact:id>
9
+ <contact:id>bb001</contact:id>
10
+ </contact:check>
11
+ </check>
12
+ </command>
13
+ </epp>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <check>
5
+ <domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>test.it</domain:name>
7
+ <domain:name>wow.it</domain:name>
8
+ </domain:check>
9
+ </check>
10
+ </command>
11
+ </epp>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <create>
5
+ <domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>architest.it</domain:name>
7
+ <domain:ns>
8
+ <domain:hostAttr>
9
+ <domain:hostName>ns.test.it</domain:hostName>
10
+ <domain:hostAddr ip="v4">192.168.100.10</domain:hostAddr>
11
+ </domain:hostAttr>
12
+ <domain:hostAttr>
13
+ <domain:hostName>ns2.test.it</domain:hostName>
14
+ <domain:hostAddr ip="v4">192.168.100.20</domain:hostAddr>
15
+ </domain:hostAttr>
16
+ <domain:hostAttr>
17
+ <domain:hostName>ns3.foo.com</domain:hostName>
18
+ </domain:hostAttr>
19
+ </domain:ns>
20
+ <domain:registrant>RRR12</domain:registrant>
21
+ <domain:contact type="admin">AAAA12</domain:contact>
22
+ <domain:contact type="tech">TTT12</domain:contact>
23
+ <domain:authInfo>
24
+ <domain:pw>WWW-test-it</domain:pw>
25
+ </domain:authInfo>
26
+ </domain:create>
27
+ </create>
28
+ </command>
29
+ </epp>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <transfer op="request">
5
+ <domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>test.it</domain:name>
7
+ <domain:authInfo>
8
+ <domain:pw>wee-12-sd</domain:pw>
9
+ </domain:authInfo>
10
+ </domain:transfer>
11
+ </transfer>
12
+ <extension>
13
+ <extdom:trade xmlns:extdom="http://www.nic.it/ITNIC-EPP/extdom-2.0" xsi:schemaLocation="http://www.nic.it/ITNIC-EPP/extdom-2.0 extdom-2.0.xsd">
14
+ <extdom:transferTrade>
15
+ <extdom:newRegistrant>xx123fd</extdom:newRegistrant>
16
+ <extdom:newAuthInfo>
17
+ <extdom:pw>abc-sd934-sd</extdom:pw>
18
+ </extdom:newAuthInfo>
19
+ </extdom:transferTrade>
20
+ </extdom:trade>
21
+ </extension>
22
+ </command>
23
+ </epp>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <transfer op="request">
5
+ <domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>test.it</domain:name>
7
+ <domain:authInfo>
8
+ <domain:pw>wee-12-sd</domain:pw>
9
+ </domain:authInfo>
10
+ </domain:transfer>
11
+ </transfer>
12
+ </command>
13
+ </epp>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ </domain:update>
8
+ </update>
9
+ <extension>
10
+ <rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:rgp-1.0 rgp-1.0.xsd">
11
+ <rgp:restore op="request"/>
12
+ </rgp:update>
13
+ </extension>
14
+ </command>
15
+ </epp>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ <domain:chg>
8
+ <domain:authInfo>
9
+ <domain:pw>AUTH12-!DSRTG</domain:pw>
10
+ </domain:authInfo>
11
+ </domain:chg>
12
+ </domain:update>
13
+ </update>
14
+ </command>
15
+ </epp>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ <domain:chg>
8
+ <domain:registrant>R0001</domain:registrant>
9
+ <domain:authInfo>
10
+ <domain:pw>AUTH12-!DSRTG</domain:pw>
11
+ </domain:authInfo>
12
+ </domain:chg>
13
+ </domain:update>
14
+ </update>
15
+ </command>
16
+ </epp>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ <domain:add>
8
+ <domain:contact type="admin">AAA1</domain:contact>
9
+ <domain:contact type="tech">TTT1</domain:contact>
10
+ </domain:add>
11
+ <domain:rem>
12
+ <domain:contact type="admin">AAA2</domain:contact>
13
+ <domain:contact type="tech">TTT2</domain:contact>
14
+ </domain:rem>
15
+ </domain:update>
16
+ </update>
17
+ </command>
18
+ </epp>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ <domain:add>
8
+ <domain:ns>
9
+ <domain:hostAttr>
10
+ <domain:hostName>ns1.example.com</domain:hostName>
11
+ <domain:hostAddr ip="v4">192.168.1.1</domain:hostAddr>
12
+ </domain:hostAttr>
13
+ <domain:hostAttr>
14
+ <domain:hostName>ns3.example.com</domain:hostName>
15
+ </domain:hostAttr>
16
+ </domain:ns>
17
+ </domain:add>
18
+ <domain:rem>
19
+ <domain:ns>
20
+ <domain:hostAttr>
21
+ <domain:hostName>ns2.example.com</domain:hostName>
22
+ </domain:hostAttr>
23
+ </domain:ns>
24
+ </domain:rem>
25
+ </domain:update>
26
+ </update>
27
+ </command>
28
+ </epp>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
3
+ <command>
4
+ <update>
5
+ <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
6
+ <domain:name>example.com</domain:name>
7
+ <domain:add>
8
+ <domain:status s="clientTransferProhibited"/>
9
+ </domain:add>
10
+ <domain:rem>
11
+ <domain:status s="clientHold"/>
12
+ </domain:rem>
13
+ </domain:update>
14
+ </update>
15
+ </command>
16
+ </epp>
@@ -0,0 +1,111 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_group "Commands","lib/epp/epp_command"
7
+ end
8
+
9
+ require 'kono_epp_client' # and any other gems you need
10
+
11
+ # This file was generated by the `rspec --init` command. Conventionally, all
12
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
13
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
14
+ # this file to always be loaded, without a need to explicitly require it in any
15
+ # files.
16
+ #
17
+ # Given that it is always loaded, you are encouraged to keep this file as
18
+ # light-weight as possible. Requiring heavyweight dependencies from this file
19
+ # will add to the boot time of your test suite on EVERY test run, even for an
20
+ # individual file that may not need all of that loaded. Instead, consider making
21
+ # a separate helper file that requires the additional dependencies and performs
22
+ # the additional setup, and require it from the spec files that actually need
23
+ # it.
24
+ #
25
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
26
+ Dir[File.join(File.dirname(__FILE__),"support/*.rb")].each { |f| require f }
27
+
28
+ RSpec.configure do |config|
29
+
30
+ # rspec-expectations config goes here. You can use an alternate
31
+ # assertion/expectation library such as wrong or the stdlib/minitest
32
+ # assertions if you prefer.
33
+ config.expect_with :rspec do |expectations|
34
+ # This option will default to `true` in RSpec 4. It makes the `description`
35
+ # and `failure_message` of custom matchers include text for helper methods
36
+ # defined using `chain`, e.g.:
37
+ # be_bigger_than(2).and_smaller_than(4).description
38
+ # # => "be bigger than 2 and smaller than 4"
39
+ # ...rather than:
40
+ # # => "be bigger than 2"
41
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
42
+ end
43
+
44
+ # rspec-mocks config goes here. You can use an alternate test double
45
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
46
+ config.mock_with :rspec do |mocks|
47
+ # Prevents you from mocking or stubbing a method that does not exist on
48
+ # a real object. This is generally recommended, and will default to
49
+ # `true` in RSpec 4.
50
+ mocks.verify_partial_doubles = true
51
+ end
52
+
53
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
54
+ # have no way to turn it off -- the option exists only for backwards
55
+ # compatibility in RSpec 3). It causes shared context metadata to be
56
+ # inherited by the metadata hash of host groups and examples, rather than
57
+ # triggering implicit auto-inclusion in groups with matching metadata.
58
+ config.shared_context_metadata_behavior = :apply_to_host_groups
59
+
60
+ # The settings below are suggested to provide a good initial experience
61
+ # with RSpec, but feel free to customize to your heart's content.
62
+ =begin
63
+ # This allows you to limit a spec run to individual examples or groups
64
+ # you care about by tagging them with `:focus` metadata. When nothing
65
+ # is tagged with `:focus`, all examples get run. RSpec also provides
66
+ # aliases for `it`, `describe`, and `context` that include `:focus`
67
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
68
+ config.filter_run_when_matching :focus
69
+
70
+ # Allows RSpec to persist some state between runs in order to support
71
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
72
+ # you configure your source control system to ignore this file.
73
+ config.example_status_persistence_file_path = "spec/examples.txt"
74
+
75
+ # Limits the available syntax to the non-monkey patched syntax that is
76
+ # recommended. For more details, see:
77
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
78
+ config.disable_monkey_patching!
79
+
80
+ # This setting enables warnings. It's recommended, but in some cases may
81
+ # be too noisy due to issues in dependencies.
82
+ config.warnings = true
83
+
84
+ # Many RSpec users commonly either run the entire suite or an individual
85
+ # file, and it's useful to allow more verbose output when running an
86
+ # individual spec file.
87
+ if config.files_to_run.one?
88
+ # Use the documentation formatter for detailed output,
89
+ # unless a formatter has already been configured
90
+ # (e.g. via a command-line flag).
91
+ config.default_formatter = "doc"
92
+ end
93
+
94
+ # Print the 10 slowest examples and example groups at the
95
+ # end of the spec run, to help surface which specs are running
96
+ # particularly slow.
97
+ config.profile_examples = 10
98
+
99
+ # Run specs in random order to surface order dependencies. If you find an
100
+ # order dependency and want to debug it, you can fix the order by providing
101
+ # the seed, which is printed after each run.
102
+ # --seed 1234
103
+ config.order = :random
104
+
105
+ # Seed global randomization in this process using the `--seed` CLI option.
106
+ # Setting this allows you to use `--seed` to deterministically reproduce
107
+ # test failures related to randomization by passing the same `--seed` value
108
+ # as the one that triggered the failure.
109
+ Kernel.srand config.seed
110
+ =end
111
+ end
@@ -0,0 +1,15 @@
1
+ RSpec.shared_context "like epp command" do
2
+
3
+ let(:instance) {
4
+ described_class.new
5
+ }
6
+
7
+ let(:raw_rendered_content) {
8
+ instance.to_s
9
+ }
10
+ let(:rendered) {
11
+ x = Nokogiri::XML(raw_rendered_content)
12
+ x.remove_namespaces! # FIXME non capisco come funzioni la ricerca con namespace
13
+ x
14
+ }
15
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec-html-matchers'
2
+
3
+ RSpec.configure do |config|
4
+
5
+ config.include RSpecHtmlMatchers
6
+ end
@@ -0,0 +1,20 @@
1
+ require "rspec/snapshot"
2
+ require "active_support/core_ext/string"
3
+ RSpec.configure do |config|
4
+
5
+ config.snapshot_dir = "spec/fixtures/snapshots"
6
+
7
+ config.after(:each, snapshot: true) do |example|
8
+ extension=nil
9
+ extension = ".#{example.metadata[:snapshot]}" unless example.metadata[:snapshot] === true
10
+ class_name = example.metadata[:described_class].name.underscore
11
+ test_name = example.metadata[:full_description].gsub(example.metadata[:described_class].name, "").tr(" ", "_")
12
+ raise "component snapshot has no content" if raw_rendered_content.blank?
13
+ str_content = raw_rendered_content
14
+ if extension == ".xml"
15
+ str_content = Nokogiri.XML(str_content).to_xml
16
+ end
17
+ expect(str_content).to match_snapshot("#{class_name}/#{test_name}#{extension}")
18
+ end
19
+
20
+ end