dnsimple 4.6.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +9 -13
  5. data/.rubocop_dnsimple.yml +42 -40
  6. data/.rubocop_todo.yml +44 -5
  7. data/.travis.yml +14 -8
  8. data/CHANGELOG.md +56 -26
  9. data/CONTRIBUTING.md +43 -0
  10. data/Gemfile +6 -1
  11. data/LICENSE.txt +1 -1
  12. data/README.md +10 -7
  13. data/dnsimple.gemspec +3 -3
  14. data/lib/dnsimple.rb +2 -0
  15. data/lib/dnsimple/client.rb +23 -13
  16. data/lib/dnsimple/client/accounts.rb +2 -0
  17. data/lib/dnsimple/client/certificates.rb +2 -0
  18. data/lib/dnsimple/client/clients.rb +5 -2
  19. data/lib/dnsimple/client/contacts.rb +2 -0
  20. data/lib/dnsimple/client/domains.rb +3 -19
  21. data/lib/dnsimple/client/domains_collaborators.rb +2 -0
  22. data/lib/dnsimple/client/domains_delegation_signer_records.rb +2 -0
  23. data/lib/dnsimple/client/domains_dnssec.rb +2 -0
  24. data/lib/dnsimple/client/domains_email_forwards.rb +2 -0
  25. data/lib/dnsimple/client/domains_pushes.rb +2 -0
  26. data/lib/dnsimple/client/identity.rb +2 -0
  27. data/lib/dnsimple/client/oauth.rb +2 -0
  28. data/lib/dnsimple/client/registrar.rb +69 -0
  29. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -0
  30. data/lib/dnsimple/client/registrar_delegation.rb +2 -0
  31. data/lib/dnsimple/client/registrar_whois_privacy.rb +3 -1
  32. data/lib/dnsimple/client/services.rb +2 -0
  33. data/lib/dnsimple/client/services_domains.rb +2 -0
  34. data/lib/dnsimple/client/templates.rb +2 -0
  35. data/lib/dnsimple/client/templates_domains.rb +2 -0
  36. data/lib/dnsimple/client/templates_records.rb +2 -0
  37. data/lib/dnsimple/client/tlds.rb +2 -0
  38. data/lib/dnsimple/client/vanity_name_servers.rb +12 -10
  39. data/lib/dnsimple/client/webhooks.rb +2 -0
  40. data/lib/dnsimple/client/zones.rb +2 -0
  41. data/lib/dnsimple/client/zones_distributions.rb +2 -0
  42. data/lib/dnsimple/client/zones_records.rb +2 -0
  43. data/lib/dnsimple/default.rb +12 -10
  44. data/lib/dnsimple/error.rb +3 -1
  45. data/lib/dnsimple/extra.rb +4 -2
  46. data/lib/dnsimple/options.rb +2 -0
  47. data/lib/dnsimple/response.rb +7 -7
  48. data/lib/dnsimple/struct.rb +3 -0
  49. data/lib/dnsimple/struct/account.rb +2 -0
  50. data/lib/dnsimple/struct/certificate.rb +4 -2
  51. data/lib/dnsimple/struct/certificate_bundle.rb +5 -0
  52. data/lib/dnsimple/struct/certificate_purchase.rb +2 -0
  53. data/lib/dnsimple/struct/certificate_renewal.rb +2 -0
  54. data/lib/dnsimple/struct/collaborator.rb +2 -0
  55. data/lib/dnsimple/struct/contact.rb +2 -0
  56. data/lib/dnsimple/struct/delegation_signer_record.rb +2 -0
  57. data/lib/dnsimple/struct/dnssec.rb +2 -0
  58. data/lib/dnsimple/struct/domain.rb +4 -3
  59. data/lib/dnsimple/struct/domain_check.rb +2 -0
  60. data/lib/dnsimple/struct/domain_premium_price.rb +2 -0
  61. data/lib/dnsimple/struct/domain_price.rb +24 -0
  62. data/lib/dnsimple/struct/domain_push.rb +2 -0
  63. data/lib/dnsimple/struct/domain_registration.rb +2 -0
  64. data/lib/dnsimple/struct/domain_renewal.rb +2 -0
  65. data/lib/dnsimple/struct/domain_transfer.rb +5 -0
  66. data/lib/dnsimple/struct/email_forward.rb +2 -0
  67. data/lib/dnsimple/struct/extended_attribute.rb +2 -0
  68. data/lib/dnsimple/struct/oauth_token.rb +2 -0
  69. data/lib/dnsimple/struct/service.rb +2 -0
  70. data/lib/dnsimple/struct/template.rb +2 -0
  71. data/lib/dnsimple/struct/template_record.rb +2 -0
  72. data/lib/dnsimple/struct/tld.rb +2 -0
  73. data/lib/dnsimple/struct/user.rb +2 -0
  74. data/lib/dnsimple/struct/vanity_name_server.rb +2 -0
  75. data/lib/dnsimple/struct/webhook.rb +2 -0
  76. data/lib/dnsimple/struct/whoami.rb +2 -0
  77. data/lib/dnsimple/struct/whois_privacy.rb +2 -0
  78. data/lib/dnsimple/struct/whois_privacy_renewal.rb +2 -0
  79. data/lib/dnsimple/struct/zone.rb +2 -0
  80. data/lib/dnsimple/struct/zone_distribution.rb +2 -0
  81. data/lib/dnsimple/struct/zone_file.rb +2 -0
  82. data/lib/dnsimple/struct/zone_record.rb +2 -0
  83. data/lib/dnsimple/version.rb +3 -1
  84. data/spec/dnsimple/client/accounts_spec.rb +2 -0
  85. data/spec/dnsimple/client/certificates_spec.rb +35 -33
  86. data/spec/dnsimple/client/client_service_spec.rb +3 -1
  87. data/spec/dnsimple/client/contacts_spec.rb +4 -2
  88. data/spec/dnsimple/client/domains_collaborators_spec.rb +4 -2
  89. data/spec/dnsimple/client/domains_delegation_signer_records_spec.rb +3 -1
  90. data/spec/dnsimple/client/domains_dnssec_spec.rb +2 -0
  91. data/spec/dnsimple/client/domains_email_forwards_spec.rb +10 -8
  92. data/spec/dnsimple/client/domains_pushes_spec.rb +4 -2
  93. data/spec/dnsimple/client/domains_spec.rb +16 -41
  94. data/spec/dnsimple/client/identity_spec.rb +2 -0
  95. data/spec/dnsimple/client/oauth_spec.rb +2 -0
  96. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +2 -0
  97. data/spec/dnsimple/client/registrar_delegation_spec.rb +4 -2
  98. data/spec/dnsimple/client/registrar_spec.rb +116 -4
  99. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +2 -0
  100. data/spec/dnsimple/client/services_domains_spec.rb +4 -4
  101. data/spec/dnsimple/client/services_spec.rb +3 -3
  102. data/spec/dnsimple/client/templates_domains_spec.rb +2 -0
  103. data/spec/dnsimple/client/templates_records_spec.rb +3 -1
  104. data/spec/dnsimple/client/templates_spec.rb +4 -2
  105. data/spec/dnsimple/client/tlds_spec.rb +2 -0
  106. data/spec/dnsimple/client/vanity_name_servers_spec.rb +2 -0
  107. data/spec/dnsimple/client/webhooks_spec.rb +3 -1
  108. data/spec/dnsimple/client/zones_distributions_spec.rb +2 -0
  109. data/spec/dnsimple/client/zones_records_spec.rb +4 -2
  110. data/spec/dnsimple/client/zones_spec.rb +3 -1
  111. data/spec/dnsimple/client_spec.rb +18 -16
  112. data/spec/dnsimple/extra_spec.rb +2 -0
  113. data/spec/dnsimple/options/base_spec.rb +2 -0
  114. data/spec/dnsimple/options/list_options_spec.rb +6 -4
  115. data/spec/fixtures.http/accounts/success-account.http +0 -1
  116. data/spec/fixtures.http/accounts/success-user.http +0 -1
  117. data/spec/fixtures.http/addCollaborator/invite-success.http +0 -1
  118. data/spec/fixtures.http/addCollaborator/success.http +0 -1
  119. data/spec/fixtures.http/appliedServices/success.http +0 -1
  120. data/spec/fixtures.http/cancelDomainTransfer/success.http +18 -0
  121. data/spec/fixtures.http/changeDomainDelegation/success.http +0 -1
  122. data/spec/fixtures.http/changeDomainDelegationToVanity/success.http +0 -1
  123. data/spec/fixtures.http/checkDomain/success.http +0 -1
  124. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_not_a_premium_domain.http +18 -0
  125. data/spec/fixtures.http/checkDomainPremiumPrice/error_400_tld_not_supported.http +18 -0
  126. data/spec/fixtures.http/checkDomainPremiumPrice/success.http +20 -0
  127. data/spec/fixtures.http/checkZoneDistribution/error.http +0 -1
  128. data/spec/fixtures.http/checkZoneDistribution/failure.http +0 -1
  129. data/spec/fixtures.http/checkZoneDistribution/success.http +0 -1
  130. data/spec/fixtures.http/checkZoneRecordDistribution/error.http +0 -1
  131. data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +0 -1
  132. data/spec/fixtures.http/checkZoneRecordDistribution/success.http +0 -1
  133. data/spec/fixtures.http/createContact/created.http +0 -1
  134. data/spec/fixtures.http/createDelegationSignerRecord/created.http +0 -1
  135. data/spec/fixtures.http/createDelegationSignerRecord/validation-error.http +0 -1
  136. data/spec/fixtures.http/createDomain/created.http +20 -16
  137. data/spec/fixtures.http/createEmailForward/created.http +21 -17
  138. data/spec/fixtures.http/createPrimaryServer/created.http +21 -0
  139. data/spec/fixtures.http/createSecondaryZone/created.http +21 -0
  140. data/spec/fixtures.http/createTemplate/created.http +0 -1
  141. data/spec/fixtures.http/createTemplateRecord/created.http +0 -1
  142. data/spec/fixtures.http/createWebhook/created.http +0 -1
  143. data/spec/fixtures.http/createZoneRecord/created-apex.http +0 -1
  144. data/spec/fixtures.http/createZoneRecord/created.http +0 -1
  145. data/spec/fixtures.http/deleteContact/error-contact-in-use.http +18 -0
  146. data/spec/fixtures.http/deleteEmailForward/success.http +12 -7
  147. data/spec/fixtures.http/disableDnssec/not-enabled.http +0 -1
  148. data/spec/fixtures.http/disableWhoisPrivacy/success.http +0 -1
  149. data/spec/fixtures.http/downloadCertificate/success.http +0 -1
  150. data/spec/fixtures.http/enableDnssec/success.http +0 -1
  151. data/spec/fixtures.http/enableVanityNameServers/success.http +0 -1
  152. data/spec/fixtures.http/enableWhoisPrivacy/created.http +0 -1
  153. data/spec/fixtures.http/enableWhoisPrivacy/success.http +0 -1
  154. data/spec/fixtures.http/getCertificate/success.http +10 -11
  155. data/spec/fixtures.http/getCertificatePrivateKey/success.http +0 -1
  156. data/spec/fixtures.http/getContact/success.http +0 -1
  157. data/spec/fixtures.http/getDelegationSignerRecord/success.http +0 -1
  158. data/spec/fixtures.http/getDnssec/success.http +0 -1
  159. data/spec/fixtures.http/getDomain/success.http +13 -9
  160. data/spec/fixtures.http/getDomainDelegation/success-empty.http +0 -1
  161. data/spec/fixtures.http/getDomainDelegation/success.http +0 -1
  162. data/spec/fixtures.http/getDomainPremiumPrice/failure.http +0 -1
  163. data/spec/fixtures.http/getDomainPremiumPrice/success.http +0 -1
  164. data/spec/fixtures.http/getDomainPrices/failure.http +19 -0
  165. data/spec/fixtures.http/getDomainPrices/success.http +21 -0
  166. data/spec/fixtures.http/getDomainTransfer/success.http +20 -0
  167. data/spec/fixtures.http/getEmailForward/success.http +14 -10
  168. data/spec/fixtures.http/getPrimaryServer/success.http +21 -0
  169. data/spec/fixtures.http/getService/success.http +0 -1
  170. data/spec/fixtures.http/getTemplate/success.http +0 -1
  171. data/spec/fixtures.http/getTemplateRecord/success.http +0 -1
  172. data/spec/fixtures.http/getTld/success.http +0 -1
  173. data/spec/fixtures.http/getTldExtendedAttributes/success-attributes.http +0 -1
  174. data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +0 -1
  175. data/spec/fixtures.http/getTldExtendedAttributes/success.http +0 -1
  176. data/spec/fixtures.http/getWebhook/success.http +0 -1
  177. data/spec/fixtures.http/getWhoisPrivacy/success.http +0 -1
  178. data/spec/fixtures.http/getZone/success.http +0 -1
  179. data/spec/fixtures.http/getZoneFile/success.http +0 -1
  180. data/spec/fixtures.http/getZoneRecord/success.http +0 -1
  181. data/spec/fixtures.http/initiatePush/success.http +0 -1
  182. data/spec/fixtures.http/issueLetsencryptCertificate/success.http +18 -21
  183. data/spec/fixtures.http/issueRenewalLetsencryptCertificate/success.http +18 -21
  184. data/spec/fixtures.http/linkPrimaryServer/success.http +21 -0
  185. data/spec/fixtures.http/listAccounts/success-account.http +0 -1
  186. data/spec/fixtures.http/listAccounts/success-user.http +0 -1
  187. data/spec/fixtures.http/listCertificates/success.http +10 -11
  188. data/spec/fixtures.http/listCollaborators/success.http +0 -1
  189. data/spec/fixtures.http/listContacts/success.http +0 -1
  190. data/spec/fixtures.http/listDelegationSignerRecords/success.http +0 -1
  191. data/spec/fixtures.http/listDomains/success.http +20 -16
  192. data/spec/fixtures.http/listEmailForwards/success.http +0 -1
  193. data/spec/fixtures.http/listPrimaryServers/success.http +21 -0
  194. data/spec/fixtures.http/listPushes/success.http +0 -1
  195. data/spec/fixtures.http/listServices/success.http +0 -1
  196. data/spec/fixtures.http/listTemplateRecords/success.http +0 -1
  197. data/spec/fixtures.http/listTemplates/success.http +0 -1
  198. data/spec/fixtures.http/listTlds/success.http +0 -1
  199. data/spec/fixtures.http/listWebhooks/success.http +0 -1
  200. data/spec/fixtures.http/listZoneRecords/success.http +0 -1
  201. data/spec/fixtures.http/listZones/success.http +0 -1
  202. data/spec/fixtures.http/method-not-allowed.http +0 -1
  203. data/spec/fixtures.http/notfound-certificate.http +0 -1
  204. data/spec/fixtures.http/notfound-collaborator.http +0 -1
  205. data/spec/fixtures.http/notfound-contact.http +0 -1
  206. data/spec/fixtures.http/notfound-delegationsignerrecord.http +0 -1
  207. data/spec/fixtures.http/notfound-domain.http +0 -1
  208. data/spec/fixtures.http/notfound-domainpush.http +0 -1
  209. data/spec/fixtures.http/notfound-emailforward.http +0 -1
  210. data/spec/fixtures.http/notfound-record.http +0 -1
  211. data/spec/fixtures.http/notfound-template.http +0 -1
  212. data/spec/fixtures.http/notfound-webhook.http +0 -1
  213. data/spec/fixtures.http/notfound-whoisprivacy.http +0 -1
  214. data/spec/fixtures.http/notfound-zone.http +0 -1
  215. data/spec/fixtures.http/oauthAccessToken/error-invalid-request.http +0 -1
  216. data/spec/fixtures.http/oauthAccessToken/success.http +0 -1
  217. data/spec/fixtures.http/pages-1of3.http +0 -1
  218. data/spec/fixtures.http/pages-2of3.http +0 -1
  219. data/spec/fixtures.http/pages-3of3.http +0 -1
  220. data/spec/fixtures.http/purchaseLetsencryptCertificate/success.http +20 -21
  221. data/spec/fixtures.http/purchaseRenewalLetsencryptCertificate/success.http +20 -21
  222. data/spec/fixtures.http/registerDomain/success.http +1 -2
  223. data/spec/fixtures.http/renewDomain/error-tooearly.http +0 -1
  224. data/spec/fixtures.http/renewDomain/success.http +1 -2
  225. data/spec/fixtures.http/renewWhoisPrivacy/success.http +0 -1
  226. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-duplicated-order.http +1 -2
  227. data/spec/fixtures.http/renewWhoisPrivacy/whois-privacy-not-found.http +1 -2
  228. data/spec/fixtures.http/response.http +0 -1
  229. data/spec/fixtures.http/transferDomain/error-indnsimple.http +0 -1
  230. data/spec/fixtures.http/transferDomain/error-missing-authcode.http +0 -1
  231. data/spec/fixtures.http/transferDomain/success.http +1 -2
  232. data/spec/fixtures.http/unlinkPrimaryServer/success.http +21 -0
  233. data/spec/fixtures.http/updateContact/success.http +0 -1
  234. data/spec/fixtures.http/updateTemplate/success.http +0 -1
  235. data/spec/fixtures.http/updateZoneRecord/success.http +0 -1
  236. data/spec/fixtures.http/validation-error.http +0 -1
  237. data/spec/fixtures.http/whoami/success-account.http +0 -1
  238. data/spec/fixtures.http/whoami/success-user.http +0 -1
  239. data/spec/fixtures.http/whoami/success.http +0 -1
  240. data/spec/spec_helper.rb +3 -1
  241. data/spec/support/helpers.rb +2 -0
  242. data/spec/support/webmock.rb +2 -0
  243. metadata +36 -15
  244. data/.ruby-gemset +0 -1
  245. data/spec/fixtures.http/resetDomainToken/success.http +0 -17
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".templates" do
@@ -75,13 +77,13 @@ describe Dnsimple::Client, ".templates" do
75
77
 
76
78
  describe "#create_template" do
77
79
  let(:account_id) { 1010 }
80
+ let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
78
81
 
79
82
  before do
80
83
  stub_request(:post, %r{/v2/#{account_id}/templates$})
81
84
  .to_return(read_http_fixture("createTemplate/created.http"))
82
85
  end
83
86
 
84
- let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
85
87
 
86
88
  it "builds the correct request" do
87
89
  subject.create_template(account_id, attributes)
@@ -136,6 +138,7 @@ describe Dnsimple::Client, ".templates" do
136
138
 
137
139
  describe "#update_template" do
138
140
  let(:account_id) { 1010 }
141
+ let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
139
142
  let(:template_id) { 1 }
140
143
 
141
144
  before do
@@ -143,7 +146,6 @@ describe Dnsimple::Client, ".templates" do
143
146
  .to_return(read_http_fixture("updateTemplate/success.http"))
144
147
  end
145
148
 
146
- let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
147
149
 
148
150
  it "builds the correct request" do
149
151
  subject.update_template(account_id, template_id, attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".tlds" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".vanity_name_servers" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".webhooks" do
@@ -47,13 +49,13 @@ describe Dnsimple::Client, ".webhooks" do
47
49
 
48
50
  describe "#create_webhook" do
49
51
  let(:account_id) { 1010 }
52
+ let(:attributes) { { url: "https://webhook.test" } }
50
53
 
51
54
  before do
52
55
  stub_request(:post, %r{/v2/#{account_id}/webhooks$})
53
56
  .to_return(read_http_fixture("createWebhook/created.http"))
54
57
  end
55
58
 
56
- let(:attributes) { { url: "https://webhook.test" } }
57
59
 
58
60
  it "builds the correct request" do
59
61
  subject.create_webhook(account_id, attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".zones" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".zones" do
@@ -110,6 +112,7 @@ describe Dnsimple::Client, ".zones" do
110
112
 
111
113
  describe "#create_zone_record" do
112
114
  let(:account_id) { 1010 }
115
+ let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
113
116
  let(:zone_id) { "example.com" }
114
117
 
115
118
  before do
@@ -117,7 +120,6 @@ describe Dnsimple::Client, ".zones" do
117
120
  .to_return(read_http_fixture("createZoneRecord/created.http"))
118
121
  end
119
122
 
120
- let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
121
123
 
122
124
  it "builds the correct request" do
123
125
  subject.create_zone_record(account_id, zone_id, attributes)
@@ -214,6 +216,7 @@ describe Dnsimple::Client, ".zones" do
214
216
 
215
217
  describe "#update_zone_record" do
216
218
  let(:account_id) { 1010 }
219
+ let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
217
220
  let(:zone_id) { "example.com" }
218
221
  let(:record_id) { 5 }
219
222
 
@@ -222,7 +225,6 @@ describe Dnsimple::Client, ".zones" do
222
225
  .to_return(read_http_fixture("updateZoneRecord/success.http"))
223
226
  end
224
227
 
225
- let(:attributes) { { content: "mxb.example.com", priority: "20", regions: ['global'] } }
226
228
 
227
229
  it "builds the correct request" do
228
230
  subject.update_zone_record(account_id, zone_id, record_id, attributes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client, ".zones" do
@@ -87,7 +89,7 @@ describe Dnsimple::Client, ".zones" do
87
89
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&sort=name:desc")
88
90
  end
89
91
 
90
- it "supports sorting" do
92
+ it "supports filtering" do
91
93
  subject.all_zones(account_id, filter: { name_like: "zone.test" })
92
94
 
93
95
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones?page=1&per_page=100&name_like=zone.test")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Client do
@@ -47,35 +49,35 @@ describe Dnsimple::Client do
47
49
 
48
50
  describe "#get" do
49
51
  it "delegates to #request" do
50
- expect(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
52
+ allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
51
53
  expect(subject.get("path", foo: "bar")).to eq(:returned)
52
54
  end
53
55
  end
54
56
 
55
57
  describe "#post" do
56
58
  it "delegates to #request" do
57
- expect(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned)
59
+ allow(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned)
58
60
  expect(subject.post("path", foo: "bar")).to eq(:returned)
59
61
  end
60
62
  end
61
63
 
62
64
  describe "#put" do
63
65
  it "delegates to #request" do
64
- expect(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned)
66
+ allow(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned)
65
67
  expect(subject.put("path", foo: "bar")).to eq(:returned)
66
68
  end
67
69
  end
68
70
 
69
71
  describe "#patch" do
70
72
  it "delegates to #request" do
71
- expect(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned)
73
+ allow(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned)
72
74
  expect(subject.patch("path", foo: "bar")).to eq(:returned)
73
75
  end
74
76
  end
75
77
 
76
78
  describe "#delete" do
77
79
  it "delegates to #request" do
78
- expect(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned)
80
+ allow(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned)
79
81
  expect(subject.delete("path", foo: "bar")).to eq(:returned)
80
82
  end
81
83
  end
@@ -124,20 +126,20 @@ describe Dnsimple::Client do
124
126
  it "delegates to HTTParty" do
125
127
  stub_request(:get, %r{/foo})
126
128
 
127
- expect(HTTParty).to receive(:get)
129
+ allow(HTTParty).to receive(:get)
128
130
  .with(
129
131
  "#{subject.base_url}foo",
130
132
  format: :json,
131
133
  basic_auth: { username: "user", password: "pass" },
132
134
  headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
133
135
  )
134
- .and_return(double('response', code: 200))
136
+ .and_return(instance_double('response', code: 200))
135
137
 
136
138
  subject.request(:get, 'foo')
137
139
  end
138
140
 
139
141
  it "properly extracts processes options and encodes data" do
140
- expect(HTTParty).to receive(:put)
142
+ allow(HTTParty).to receive(:put)
141
143
  .with(
142
144
  "#{subject.base_url}foo",
143
145
  format: :json,
@@ -146,13 +148,13 @@ describe Dnsimple::Client do
146
148
  basic_auth: { username: "user", password: "pass" },
147
149
  headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" }
148
150
  )
149
- .and_return(double('response', code: 200))
151
+ .and_return(instance_double('response', code: 200))
150
152
 
151
153
  subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } })
152
154
  end
153
155
 
154
156
  it "handles non application/json content types" do
155
- expect(HTTParty).to receive(:post)
157
+ allow(HTTParty).to receive(:post)
156
158
  .with(
157
159
  "#{subject.base_url}foo",
158
160
  format: :json,
@@ -160,13 +162,13 @@ describe Dnsimple::Client do
160
162
  basic_auth: { username: "user", password: "pass" },
161
163
  headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT }
162
164
  )
163
- .and_return(double('response', code: 200))
165
+ .and_return(instance_double('response', code: 200))
164
166
 
165
167
  subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } })
166
168
  end
167
169
 
168
170
  it "includes options for proxy support" do
169
- expect(HTTParty).to receive(:get)
171
+ allow(HTTParty).to receive(:get)
170
172
  .with(
171
173
  "#{subject.base_url}test",
172
174
  format: :json,
@@ -174,20 +176,20 @@ describe Dnsimple::Client do
174
176
  http_proxyport: "4321",
175
177
  headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
176
178
  )
177
- .and_return(double('response', code: 200))
179
+ .and_return(instance_double('response', code: 200))
178
180
 
179
181
  subject = described_class.new(proxy: "example-proxy.com:4321")
180
182
  subject.request(:get, "test", nil, {})
181
183
  end
182
184
 
183
185
  it "supports custom user agent" do
184
- expect(HTTParty).to receive(:get)
186
+ allow(HTTParty).to receive(:get)
185
187
  .with(
186
188
  "#{subject.base_url}test",
187
189
  format: :json,
188
- headers: hash_including("User-Agent" => "#{Dnsimple::Default::USER_AGENT} customAgent")
190
+ headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}")
189
191
  )
190
- .and_return(double("response", code: 200))
192
+ .and_return(instance_double("response", code: 200))
191
193
 
192
194
  subject = described_class.new(user_agent: "customAgent")
193
195
  subject.request(:get, "test", nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Dnsimple::Extra do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Dnsimple::Options::Base do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Dnsimple::Options::ListOptions do
@@ -12,14 +14,14 @@ RSpec.describe Dnsimple::Options::ListOptions do
12
14
  expect(options.to_h).to eq({})
13
15
  end
14
16
 
15
- context 'query' do
17
+ describe 'query' do
16
18
  it 'adds "query" key if given options are filled' do
17
19
  options = described_class.new(a: 1)
18
20
  expect(options.to_h).to have_key(:query)
19
21
  end
20
22
  end
21
23
 
22
- context 'pagination' do
24
+ describe 'pagination' do
23
25
  it 'adds "page" to "query"' do
24
26
  raw = { page: '23' }
25
27
  expected = { query: raw }
@@ -45,7 +47,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
45
47
  end
46
48
  end
47
49
 
48
- context 'sorting' do
50
+ describe 'sorting' do
49
51
  it 'adds sorting policy to "query"' do
50
52
  raw = { sort: 'name:desc' }
51
53
  expected = { query: raw }
@@ -71,7 +73,7 @@ RSpec.describe Dnsimple::Options::ListOptions do
71
73
  end
72
74
  end
73
75
 
74
- context 'filtering' do
76
+ describe 'filtering' do
75
77
  it 'adds filtering policy to "query"' do
76
78
  raw = { filter: { name_like: 'example' } }
77
79
  expected = { query: raw.fetch(:filter) }
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Tue, 14 Jun 2016 12:02:58 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2391
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Tue, 14 Jun 2016 12:05:38 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2390
@@ -2,7 +2,6 @@ HTTP/1.1 201 Created
2
2
  Server: nginx
3
3
  Date: Fri, 07 Oct 2016 08:51:12 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2398
@@ -2,7 +2,6 @@ HTTP/1.1 201 Created
2
2
  Server: nginx
3
3
  Date: Fri, 07 Oct 2016 08:53:41 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2397
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Wed, 15 Jun 2016 11:09:44 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2398
@@ -0,0 +1,18 @@
1
+ HTTP/1.1 202 Accepted
2
+ Server: nginx
3
+ Date: Fri, 05 Jun 2020 18:09:42 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2394
8
+ X-RateLimit-Reset: 1591384034
9
+ Cache-Control: no-cache
10
+ X-Request-Id: 3cf6dcfa-0bb5-439e-863a-af2ef08bc830
11
+ X-Runtime: 0.912731
12
+ X-Frame-Options: DENY
13
+ X-Content-Type-Options: nosniff
14
+ X-XSS-Protection: 1; mode=block
15
+ X-Download-Options: noopen
16
+ X-Permitted-Cross-Domain-Policies: none
17
+
18
+ {"data":{"id":361,"domain_id":182245,"registrant_id":2715,"state":"transferring","auto_renew":false,"whois_privacy":false,"status_description":null,"created_at":"2020-06-05T18:08:00Z","updated_at":"2020-06-05T18:08:04Z"}}
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Thu, 24 Mar 2016 11:17:01 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  Status: 200 OK
8
7
  X-RateLimit-Limit: 2400
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Mon, 11 Jul 2016 09:40:19 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  X-RateLimit-Limit: 2400
8
7
  X-RateLimit-Remaining: 2399
@@ -2,7 +2,6 @@ HTTP/1.1 200 OK
2
2
  Server: nginx
3
3
  Date: Fri, 26 Feb 2016 16:04:05 GMT
4
4
  Content-Type: application/json; charset=utf-8
5
- Transfer-Encoding: chunked
6
5
  Connection: keep-alive
7
6
  Status: 200 OK
8
7
  X-RateLimit-Limit: 4000
@@ -0,0 +1,18 @@
1
+ HTTP/1.1 400 Bad Request
2
+ Server: nginx
3
+ Date: Mon, 27 Jul 2020 13:43:02 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 4800
7
+ X-RateLimit-Remaining: 4786
8
+ X-RateLimit-Reset: 1595859922
9
+ Cache-Control: no-cache
10
+ X-Request-Id: 382b409c-0f90-4758-af3b-0bccd31a9d0d
11
+ X-Runtime: 1.346405
12
+ X-Frame-Options: DENY
13
+ X-Content-Type-Options: nosniff
14
+ X-XSS-Protection: 1; mode=block
15
+ X-Download-Options: noopen
16
+ X-Permitted-Cross-Domain-Policies: none
17
+
18
+ {"message":"`cocotero.love` is not a premium domain for registration"}
@@ -0,0 +1,18 @@
1
+ HTTP/1.1 400 Bad Request
2
+ Server: nginx
3
+ Date: Mon, 27 Jul 2020 13:41:23 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2398
8
+ X-RateLimit-Reset: 1595860823
9
+ Cache-Control: no-cache
10
+ X-Request-Id: 6986cca3-4f57-4814-9e81-1c484d61c7ea
11
+ X-Runtime: 0.007339
12
+ X-Frame-Options: DENY
13
+ X-Content-Type-Options: nosniff
14
+ X-XSS-Protection: 1; mode=block
15
+ X-Download-Options: noopen
16
+ X-Permitted-Cross-Domain-Policies: none
17
+
18
+ {"message":"TLD .LOVE is not supported"}