dnsimple 3.0.0.pre.beta2 → 3.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/.rubocop_dnsimple.yml +216 -0
  4. data/.rubocop_todo.yml +14 -0
  5. data/CHANGELOG.md +16 -1
  6. data/Gemfile +1 -0
  7. data/Rakefile +8 -3
  8. data/lib/dnsimple/client.rb +9 -12
  9. data/lib/dnsimple/client/clients.rb +36 -2
  10. data/lib/dnsimple/client/contacts.rb +6 -6
  11. data/lib/dnsimple/client/domains.rb +5 -5
  12. data/lib/dnsimple/client/identity.rb +2 -2
  13. data/lib/dnsimple/client/oauth.rb +2 -2
  14. data/lib/dnsimple/client/registrar.rb +1 -1
  15. data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -2
  16. data/lib/dnsimple/client/registrar_delegation.rb +49 -0
  17. data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
  18. data/lib/dnsimple/client/services.rb +68 -0
  19. data/lib/dnsimple/client/templates.rb +139 -0
  20. data/lib/dnsimple/client/tlds.rb +3 -3
  21. data/lib/dnsimple/client/webhooks.rb +4 -4
  22. data/lib/dnsimple/client/zones.rb +2 -2
  23. data/lib/dnsimple/client/zones_records.rb +1 -1
  24. data/lib/dnsimple/default.rb +2 -2
  25. data/lib/dnsimple/error.rb +14 -1
  26. data/lib/dnsimple/struct.rb +3 -1
  27. data/lib/dnsimple/struct/contact.rb +2 -2
  28. data/lib/dnsimple/struct/extended_attribute.rb +5 -1
  29. data/lib/dnsimple/struct/service.rb +64 -0
  30. data/lib/dnsimple/struct/template.rb +22 -0
  31. data/lib/dnsimple/struct/tld.rb +1 -1
  32. data/lib/dnsimple/version.rb +1 -1
  33. data/spec/dnsimple/client/client_service_spec.rb +6 -6
  34. data/spec/dnsimple/client/contacts_spec.rb +30 -30
  35. data/spec/dnsimple/client/domains_email_forwards_spec.rb +25 -25
  36. data/spec/dnsimple/client/domains_spec.rb +27 -27
  37. data/spec/dnsimple/client/identity_spec.rb +8 -8
  38. data/spec/dnsimple/client/oauth_spec.rb +9 -9
  39. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +13 -13
  40. data/spec/dnsimple/client/registrar_delegation_spec.rb +55 -0
  41. data/spec/dnsimple/client/registrar_spec.rb +29 -29
  42. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +16 -16
  43. data/spec/dnsimple/client/services_spec.rb +78 -0
  44. data/spec/dnsimple/client/templates_spec.rb +163 -0
  45. data/spec/dnsimple/client/tlds_spec.rb +22 -23
  46. data/spec/dnsimple/client/webhooks_spec.rb +22 -22
  47. data/spec/dnsimple/client/zones_records_spec.rb +40 -40
  48. data/spec/dnsimple/client/zones_spec.rb +12 -12
  49. data/spec/dnsimple/client_spec.rb +52 -44
  50. data/spec/dnsimple/extra_spec.rb +3 -3
  51. data/spec/fixtures.http/changeDomainDelegation/success.http +17 -0
  52. data/spec/fixtures.http/createTemplate/created.http +17 -0
  53. data/spec/fixtures.http/deleteTemplate/success.http +13 -0
  54. data/spec/fixtures.http/getDomainDelegation/success-empty.http +17 -0
  55. data/spec/fixtures.http/getDomainDelegation/success.http +17 -0
  56. data/spec/fixtures.http/getService/success.http +17 -0
  57. data/spec/fixtures.http/getTemplate/success.http +17 -0
  58. data/spec/fixtures.http/listServices/success.http +17 -0
  59. data/spec/fixtures.http/listTemplates/success.http +17 -0
  60. data/spec/fixtures.http/method-not-allowed.http +11 -0
  61. data/spec/fixtures.http/updateTemplate/success.http +17 -0
  62. metadata +41 -5
@@ -9,15 +9,15 @@ describe Dnsimple::Client, ".registrar" do
9
9
  let(:account_id) { 1010 }
10
10
 
11
11
  before do
12
- stub_request(:get, %r[/v2/#{account_id}/registrar/domains/.+/whois_privacy$])
13
- .to_return(read_http_fixture("getWhoisPrivacy/success.http"))
12
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy$}).
13
+ to_return(read_http_fixture("getWhoisPrivacy/success.http"))
14
14
  end
15
15
 
16
16
  it "builds the correct request" do
17
17
  subject.whois_privacy(account_id, domain_name = "example.com")
18
18
 
19
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy")
20
- .with(headers: { "Accept" => "application/json" })
19
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy").
20
+ with(headers: { "Accept" => "application/json" })
21
21
  end
22
22
 
23
23
  it "returns the whois privacy" do
@@ -37,15 +37,15 @@ describe Dnsimple::Client, ".registrar" do
37
37
 
38
38
  context "when the whois privacy had already been purchased" do
39
39
  before do
40
- stub_request(:put, %r[/v2/#{account_id}/registrar/domains/.+/whois_privacy$])
41
- .to_return(read_http_fixture("enableWhoisPrivacy/success.http"))
40
+ stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy$}).
41
+ to_return(read_http_fixture("enableWhoisPrivacy/success.http"))
42
42
  end
43
43
 
44
44
  it "builds the correct request" do
45
45
  subject.enable_whois_privacy(account_id, domain_name = "example.com")
46
46
 
47
- expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy")
48
- .with(headers: { "Accept" => "application/json" })
47
+ expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy").
48
+ with(headers: { "Accept" => "application/json" })
49
49
  end
50
50
 
51
51
  it "returns the whois privacy" do
@@ -63,15 +63,15 @@ describe Dnsimple::Client, ".registrar" do
63
63
 
64
64
  context "when the whois privacy is newly purchased" do
65
65
  before do
66
- stub_request(:put, %r[/v2/#{account_id}/registrar/domains/.+/whois_privacy$])
67
- .to_return(read_http_fixture("enableWhoisPrivacy/created.http"))
66
+ stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy$}).
67
+ to_return(read_http_fixture("enableWhoisPrivacy/created.http"))
68
68
  end
69
69
 
70
70
  it "builds the correct request" do
71
71
  subject.enable_whois_privacy(account_id, domain_name = "example.com")
72
72
 
73
- expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy")
74
- .with(headers: { "Accept" => "application/json" })
73
+ expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy").
74
+ with(headers: { "Accept" => "application/json" })
75
75
  end
76
76
 
77
77
  it "returns the whois privacy" do
@@ -93,15 +93,15 @@ describe Dnsimple::Client, ".registrar" do
93
93
  let(:account_id) { 1010 }
94
94
 
95
95
  before do
96
- stub_request(:delete, %r[/v2/#{account_id}/registrar/domains/.+/whois_privacy$])
97
- .to_return(read_http_fixture("disableWhoisPrivacy/success.http"))
96
+ stub_request(:delete, %r{/v2/#{account_id}/registrar/domains/.+/whois_privacy$}).
97
+ to_return(read_http_fixture("disableWhoisPrivacy/success.http"))
98
98
  end
99
99
 
100
100
  it "builds the correct request" do
101
101
  subject.disable_whois_privacy(account_id, domain_name = "example.com")
102
102
 
103
- expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy")
104
- .with(headers: { "Accept" => "application/json" })
103
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/whois_privacy").
104
+ with(headers: { "Accept" => "application/json" })
105
105
  end
106
106
 
107
107
  it "returns the whois privacy" do
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dnsimple::Client, ".services" do
4
+
5
+ subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").services }
6
+
7
+
8
+ describe "#list_services" do
9
+ before do
10
+ stub_request(:get, %r{/v2/services$}).
11
+ to_return(read_http_fixture("listServices/success.http"))
12
+ end
13
+
14
+ it "builds the correct request" do
15
+ subject.list_services
16
+
17
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services").
18
+ with(headers: { "Accept" => "application/json" })
19
+ end
20
+
21
+ it "returns the list of available services" do
22
+ response = subject.list_services
23
+ expect(response).to be_a(Dnsimple::CollectionResponse)
24
+
25
+ response.data.each do |service|
26
+ expect(service).to be_a(Dnsimple::Struct::Service)
27
+ expect(service.id).to be_a(Fixnum)
28
+ expect(service.name).to be_a(String)
29
+ expect(service.short_name).to be_a(String)
30
+ expect(service.description).to be_a(String)
31
+
32
+ service.settings.each do |service_setting|
33
+ expect(service_setting).to be_a(Dnsimple::Struct::Service::Setting)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#all_services" do
40
+ it "delegates to client.paginate" do
41
+ expect(subject).to receive(:paginate).with(:services, foo: "bar")
42
+ subject.all_services(foo: "bar")
43
+ end
44
+ end
45
+
46
+ describe "#service" do
47
+ let(:service_id) { 1 }
48
+
49
+ before do
50
+ stub_request(:get, %r{/v2/services/#{service_id}$}).
51
+ to_return(read_http_fixture("getService/success.http"))
52
+ end
53
+
54
+ it "builds the correct request" do
55
+ subject.service(service_id)
56
+
57
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services/#{service_id}").
58
+ with(headers: { "Accept" => "application/json" })
59
+ end
60
+
61
+ it "returns the service" do
62
+ response = subject.service(service_id)
63
+ expect(response).to be_a(Dnsimple::Response)
64
+
65
+ service = response.data
66
+ expect(service).to be_a(Dnsimple::Struct::Service)
67
+ expect(service.id).to eq(1)
68
+ expect(service.name).to eq("Service 1")
69
+ expect(service.short_name).to eq("service1")
70
+ expect(service.description).to eq("First service example.")
71
+ expect(service.setup_description).to be_nil
72
+ expect(service.requires_setup).to be_falsey
73
+ expect(service.default_subdomain).to be_nil
74
+ expect(service.settings).to eq([])
75
+ end
76
+ end
77
+
78
+ end
@@ -0,0 +1,163 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dnsimple::Client, ".templates" do
4
+
5
+ subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").templates }
6
+
7
+
8
+ describe "#list_templates" do
9
+ let(:account_id) { 1010 }
10
+
11
+ before do
12
+ stub_request(:get, %r{/v2/#{account_id}/templates$}).
13
+ to_return(read_http_fixture("listTemplates/success.http"))
14
+ end
15
+
16
+ it "builds the correct request" do
17
+ subject.list_templates(account_id)
18
+
19
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/templates").
20
+ with(headers: { "Accept" => "application/json" })
21
+ end
22
+
23
+ it "returns the list of templates" do
24
+ response = subject.list_templates(account_id)
25
+ expect(response).to be_a(Dnsimple::CollectionResponse)
26
+
27
+ response.data.each do |result|
28
+ expect(result).to be_a(Dnsimple::Struct::Template)
29
+ expect(result.id).to be_a(Numeric)
30
+ expect(result.account_id).to be_a(Numeric)
31
+ expect(result.name).to be_a(String)
32
+ expect(result.short_name).to be_a(String)
33
+ expect(result.description).to be_a(String)
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "#all_templates" do
39
+ let(:account_id) { 1010 }
40
+
41
+ it "delegates to client.paginate" do
42
+ expect(subject).to receive(:paginate).with(:templates, account_id, foo: "bar")
43
+ subject.all_templates(account_id, foo: "bar")
44
+ end
45
+ end
46
+
47
+ describe "#create_template" do
48
+ let(:account_id) { 1010 }
49
+
50
+ before do
51
+ stub_request(:post, %r{/v2/#{account_id}/templates$}).
52
+ to_return(read_http_fixture("createTemplate/created.http"))
53
+ end
54
+
55
+ let(:attributes) { { name: "Beta", short_name: "beta", description: "A beta template." } }
56
+
57
+ it "builds the correct request" do
58
+ subject.create_template(account_id, attributes)
59
+
60
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/templates").
61
+ with(headers: { "Accept" => "application/json" })
62
+ end
63
+
64
+ it "returns the list of templates" do
65
+ response = subject.create_template(account_id, attributes)
66
+ expect(response).to be_a(Dnsimple::Response)
67
+
68
+ template = response.data
69
+ expect(template).to be_a(Dnsimple::Struct::Template)
70
+ expect(template.id).to eq(1)
71
+ expect(template.account_id).to eq(1010)
72
+ expect(template.name).to eq("Beta")
73
+ expect(template.short_name).to eq("beta")
74
+ expect(template.description).to eq("A beta template.")
75
+ end
76
+ end
77
+
78
+ describe "#template" do
79
+ let(:account_id) { 1010 }
80
+ let(:template_id) { 1 }
81
+
82
+ before do
83
+ stub_request(:get, %r{/v2/#{account_id}/templates/#{template_id}$}).
84
+ to_return(read_http_fixture("getTemplate/success.http"))
85
+ end
86
+
87
+ it "builds the correct request" do
88
+ subject.template(account_id, template_id)
89
+
90
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}").
91
+ with(headers: { "Accept" => "application/json" })
92
+ end
93
+
94
+ it "returns the list of templates" do
95
+ response = subject.template(account_id, template_id)
96
+ expect(response).to be_a(Dnsimple::Response)
97
+
98
+ template = response.data
99
+ expect(template).to be_a(Dnsimple::Struct::Template)
100
+ expect(template.id).to eq(1)
101
+ expect(template.account_id).to eq(1010)
102
+ expect(template.name).to eq("Alpha")
103
+ expect(template.short_name).to eq("alpha")
104
+ expect(template.description).to eq("An alpha template.")
105
+ end
106
+ end
107
+
108
+ describe "#update_template" do
109
+ let(:account_id) { 1010 }
110
+ let(:template_id) { 1 }
111
+
112
+ before do
113
+ stub_request(:patch, %r{/v2/#{account_id}/templates/#{template_id}$}).
114
+ to_return(read_http_fixture("updateTemplate/success.http"))
115
+ end
116
+
117
+ let(:attributes) { { name: "Alpha", short_name: "alpha", description: "An alpha template." } }
118
+
119
+ it "builds the correct request" do
120
+ subject.update_template(account_id, template_id, attributes)
121
+
122
+ expect(WebMock).to have_requested(:patch, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}").
123
+ with(headers: { "Accept" => "application/json" })
124
+ end
125
+
126
+ it "returns the list of templates" do
127
+ response = subject.update_template(account_id, template_id, attributes)
128
+ expect(response).to be_a(Dnsimple::Response)
129
+
130
+ template = response.data
131
+ expect(template).to be_a(Dnsimple::Struct::Template)
132
+ expect(template.id).to eq(1)
133
+ expect(template.account_id).to eq(1010)
134
+ expect(template.name).to eq("Alpha")
135
+ expect(template.short_name).to eq("alpha")
136
+ expect(template.description).to eq("An alpha template.")
137
+ end
138
+ end
139
+
140
+ describe "#delete_template" do
141
+ let(:account_id) { 1010 }
142
+ let(:template_id) { 5410 }
143
+
144
+ before do
145
+ stub_request(:delete, %r{/v2/#{account_id}/templates/#{template_id}$}).
146
+ to_return(read_http_fixture("deleteTemplate/success.http"))
147
+ end
148
+
149
+ it "builds the correct request" do
150
+ subject.delete_template(account_id, template_id)
151
+
152
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/templates/#{template_id}").
153
+ with(headers: { "Accept" => "application/json" })
154
+ end
155
+
156
+ it "returns the list of templates" do
157
+ response = subject.delete_template(account_id, template_id)
158
+ expect(response).to be_a(Dnsimple::Response)
159
+ expect(response.data).to be_nil
160
+ end
161
+ end
162
+
163
+ end
@@ -5,15 +5,15 @@ describe Dnsimple::Client, ".tlds" do
5
5
 
6
6
  describe "#tlds" do
7
7
  before do
8
- stub_request(:get, %r[/v2/tlds])
9
- .to_return(read_http_fixture("listTlds/success.http"))
8
+ stub_request(:get, %r{/v2/tlds}).
9
+ to_return(read_http_fixture("listTlds/success.http"))
10
10
  end
11
11
 
12
12
  it "builds the correct request" do
13
13
  subject.tlds
14
14
 
15
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds")
16
- .with(headers: { 'Accept' => 'application/json' })
15
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds").
16
+ with(headers: { 'Accept' => 'application/json' })
17
17
  end
18
18
 
19
19
  it "supports pagination" do
@@ -55,22 +55,22 @@ describe Dnsimple::Client, ".tlds" do
55
55
 
56
56
  describe "#all_tlds" do
57
57
  it "delegates to client.paginate" do
58
- expect(subject).to receive(:paginate).with(:tlds, { foo: "bar" })
59
- subject.all_tlds({ foo: "bar" })
58
+ expect(subject).to receive(:paginate).with(:tlds, foo: "bar")
59
+ subject.all_tlds(foo: "bar")
60
60
  end
61
61
  end
62
62
 
63
63
  describe "#tld" do
64
64
  before do
65
- stub_request(:get, %r[/v2/tlds/.+$])
66
- .to_return(read_http_fixture("getTld/success.http"))
65
+ stub_request(:get, %r{/v2/tlds/.+$}).
66
+ to_return(read_http_fixture("getTld/success.http"))
67
67
  end
68
68
 
69
69
  it "builds the correct request" do
70
70
  subject.tld(tld = "com")
71
71
 
72
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}")
73
- .with(headers: { 'Accept' => 'application/json' })
72
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}").
73
+ with(headers: { 'Accept' => 'application/json' })
74
74
  end
75
75
 
76
76
  it "returns the tld" do
@@ -89,15 +89,15 @@ describe Dnsimple::Client, ".tlds" do
89
89
 
90
90
  describe "#extended_attributes" do
91
91
  before do
92
- stub_request(:get, %r[/v2/tlds/uk/extended_attributes$])
93
- .to_return(read_http_fixture("getTldExtendedAttributes/success.http"))
92
+ stub_request(:get, %r{/v2/tlds/uk/extended_attributes$}).
93
+ to_return(read_http_fixture("getTldExtendedAttributes/success.http"))
94
94
  end
95
95
 
96
96
  it "builds the correct request" do
97
97
  subject.extended_attributes(tld = "uk")
98
98
 
99
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}/extended_attributes")
100
- .with(headers: { 'Accept' => 'application/json' })
99
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}/extended_attributes").
100
+ with(headers: { 'Accept' => 'application/json' })
101
101
  end
102
102
 
103
103
  it "returns the extended attributes" do
@@ -110,21 +110,20 @@ describe Dnsimple::Client, ".tlds" do
110
110
  expect(result.description).to be_a(String)
111
111
  expect(result).to respond_to(:required)
112
112
 
113
- if !result.options.empty?
114
- result.options.each do |option|
115
- expect(option).to be_a(Dnsimple::Struct::ExtendedAttribute::Option)
116
- expect(option.title).to be_a(String)
117
- expect(option.value).to be_a(String)
118
- expect(option.description).to be_a(String)
119
- end
113
+ next if result.options.empty?
114
+ result.options.each do |option|
115
+ expect(option).to be_a(Dnsimple::Struct::ExtendedAttribute::Option)
116
+ expect(option.title).to be_a(String)
117
+ expect(option.value).to be_a(String)
118
+ expect(option.description).to be_a(String)
120
119
  end
121
120
  end
122
121
  end
123
122
 
124
123
  context "when there are no extended attributes for a TLD" do
125
124
  before do
126
- stub_request(:get, %r[/v2/tlds/com/extended_attributes$])
127
- .to_return(read_http_fixture("getTldExtendedAttributes/success-noattributes.http"))
125
+ stub_request(:get, %r{/v2/tlds/com/extended_attributes$}).
126
+ to_return(read_http_fixture("getTldExtendedAttributes/success-noattributes.http"))
128
127
  end
129
128
 
130
129
  it "returns an empty CollectionResponse" do
@@ -8,15 +8,15 @@ describe Dnsimple::Client, ".webhooks" do
8
8
  let(:account_id) { 1010 }
9
9
 
10
10
  before do
11
- stub_request(:get, %r[/v2/#{account_id}/webhooks])
12
- .to_return(read_http_fixture("listWebhooks/success.http"))
11
+ stub_request(:get, %r{/v2/#{account_id}/webhooks}).
12
+ to_return(read_http_fixture("listWebhooks/success.http"))
13
13
  end
14
14
 
15
15
  it "builds the correct request" do
16
16
  subject.webhooks(account_id)
17
17
 
18
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks")
19
- .with(headers: { 'Accept' => 'application/json' })
18
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks").
19
+ with(headers: { 'Accept' => 'application/json' })
20
20
  end
21
21
 
22
22
  it "supports extra request options" do
@@ -43,18 +43,18 @@ describe Dnsimple::Client, ".webhooks" do
43
43
  let(:account_id) { 1010 }
44
44
 
45
45
  before do
46
- stub_request(:post, %r[/v2/#{account_id}/webhooks$])
47
- .to_return(read_http_fixture("createWebhook/created.http"))
46
+ stub_request(:post, %r{/v2/#{account_id}/webhooks$}).
47
+ to_return(read_http_fixture("createWebhook/created.http"))
48
48
  end
49
49
 
50
- let(:attributes) { {url: "https://webhook.test"} }
50
+ let(:attributes) { { url: "https://webhook.test" } }
51
51
 
52
52
  it "builds the correct request" do
53
53
  subject.create_webhook(account_id, attributes)
54
54
 
55
- expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/webhooks")
56
- .with(body: attributes)
57
- .with(headers: { 'Accept' => 'application/json' })
55
+ expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/webhooks").
56
+ with(body: attributes).
57
+ with(headers: { 'Accept' => 'application/json' })
58
58
  end
59
59
 
60
60
  it "returns the webhook" do
@@ -71,15 +71,15 @@ describe Dnsimple::Client, ".webhooks" do
71
71
  let(:account_id) { 1010 }
72
72
 
73
73
  before do
74
- stub_request(:get, %r[/v2/#{account_id}/webhooks/.+$])
75
- .to_return(read_http_fixture("getWebhook/success.http"))
74
+ stub_request(:get, %r{/v2/#{account_id}/webhooks/.+$}).
75
+ to_return(read_http_fixture("getWebhook/success.http"))
76
76
  end
77
77
 
78
78
  it "builds the correct request" do
79
79
  subject.webhook(account_id, webhook_id = "1")
80
80
 
81
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}")
82
- .with(headers: { 'Accept' => 'application/json' })
81
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}").
82
+ with(headers: { 'Accept' => 'application/json' })
83
83
  end
84
84
 
85
85
  it "returns the webhook" do
@@ -94,8 +94,8 @@ describe Dnsimple::Client, ".webhooks" do
94
94
 
95
95
  context "when the webhook does not exist" do
96
96
  it "raises NotFoundError" do
97
- stub_request(:get, %r[/v2])
98
- .to_return(read_http_fixture("notfound-webhook.http"))
97
+ stub_request(:get, %r{/v2}).
98
+ to_return(read_http_fixture("notfound-webhook.http"))
99
99
 
100
100
  expect {
101
101
  subject.webhook(account_id, 0)
@@ -108,15 +108,15 @@ describe Dnsimple::Client, ".webhooks" do
108
108
  let(:account_id) { 1010 }
109
109
 
110
110
  before do
111
- stub_request(:delete, %r[/v2/#{account_id}/webhooks/.+$])
112
- .to_return(read_http_fixture("deleteWebhook/success.http"))
111
+ stub_request(:delete, %r{/v2/#{account_id}/webhooks/.+$}).
112
+ to_return(read_http_fixture("deleteWebhook/success.http"))
113
113
  end
114
114
 
115
115
  it "builds the correct request" do
116
116
  subject.delete_webhook(account_id, webhook_id = "1")
117
117
 
118
- expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}")
119
- .with(headers: { 'Accept' => 'application/json' })
118
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/webhooks/#{webhook_id}").
119
+ with(headers: { 'Accept' => 'application/json' })
120
120
  end
121
121
 
122
122
  it "returns nothing" do
@@ -129,8 +129,8 @@ describe Dnsimple::Client, ".webhooks" do
129
129
 
130
130
  context "when the webhook does not exist" do
131
131
  it "raises NotFoundError" do
132
- stub_request(:delete, %r[/v2])
133
- .to_return(read_http_fixture("notfound-webhook.http"))
132
+ stub_request(:delete, %r{/v2}).
133
+ to_return(read_http_fixture("notfound-webhook.http"))
134
134
 
135
135
  expect {
136
136
  subject.delete_webhook(account_id, 0)