dnsimple 2.0.0.alpha4 → 2.0.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +22 -2
  3. data/UPGRADING.markdown +102 -0
  4. data/lib/dnsimple/client.rb +37 -16
  5. data/lib/dnsimple/client/certificates.rb +9 -7
  6. data/lib/dnsimple/client/contacts.rb +7 -5
  7. data/lib/dnsimple/client/domains.rb +6 -4
  8. data/lib/dnsimple/client/domains_forwards.rb +6 -6
  9. data/lib/dnsimple/client/domains_records.rb +7 -7
  10. data/lib/dnsimple/client/domains_sharing.rb +4 -4
  11. data/lib/dnsimple/client/domains_zones.rb +1 -1
  12. data/lib/dnsimple/client/name_servers.rb +5 -3
  13. data/lib/dnsimple/client/registrar.rb +20 -7
  14. data/lib/dnsimple/client/services.rb +5 -3
  15. data/lib/dnsimple/client/services_domains.rb +4 -4
  16. data/lib/dnsimple/client/templates.rb +8 -6
  17. data/lib/dnsimple/client/templates_records.rb +7 -7
  18. data/lib/dnsimple/error.rb +1 -1
  19. data/lib/dnsimple/version.rb +1 -1
  20. data/spec/dnsimple/client/certificates_spec.rb +20 -20
  21. data/spec/dnsimple/client/contacts_spec.rb +24 -24
  22. data/spec/dnsimple/client/domains_autorenewals_spec.rb +4 -4
  23. data/spec/dnsimple/client/domains_forwards_spec.rb +17 -17
  24. data/spec/dnsimple/client/domains_privacy_spec.rb +4 -4
  25. data/spec/dnsimple/client/domains_records_spec.rb +20 -20
  26. data/spec/dnsimple/client/domains_sharing_spec.rb +12 -12
  27. data/spec/dnsimple/client/domains_spec.rb +14 -14
  28. data/spec/dnsimple/client/domains_zones_spec.rb +2 -2
  29. data/spec/dnsimple/client/name_servers_spec.rb +13 -13
  30. data/spec/dnsimple/client/registrar_spec.rb +48 -6
  31. data/spec/dnsimple/client/services_spec.rb +11 -11
  32. data/spec/dnsimple/client/templates_records_spec.rb +17 -17
  33. data/spec/dnsimple/client/templates_spec.rb +17 -17
  34. data/spec/dnsimple/client_spec.rb +23 -19
  35. data/spec/files/certificates/{show → get}/success.http +0 -0
  36. data/spec/files/certificates/{index → list}/success.http +0 -0
  37. data/spec/files/contacts/{show → get}/success.http +1 -1
  38. data/spec/files/contacts/{index → list}/success.http +1 -1
  39. data/spec/files/domains/{show → get}/success.http +0 -0
  40. data/spec/files/domains/{index → list}/success.http +0 -0
  41. data/spec/files/domains_records/{show → get}/success.http +0 -0
  42. data/spec/files/domains_records/{index → list}/success.http +0 -0
  43. data/spec/files/services/{show → get}/success.http +0 -0
  44. data/spec/files/services/{index → list}/success.http +0 -0
  45. data/spec/files/subscriptions/{show → get}/success.http +0 -0
  46. data/spec/files/templates/{show → get}/success.http +0 -0
  47. data/spec/files/templates/{index → list}/success.http +0 -0
  48. data/spec/files/templates_records/{show → get}/success.http +0 -0
  49. data/spec/files/templates_records/{index → list}/success.http +0 -0
  50. metadata +33 -32
@@ -26,13 +26,13 @@ describe Dnsimple::Client, ".domains / zones" do
26
26
  end
27
27
 
28
28
  context "when domain does not exist" do
29
- it "raises RecordNotFound" do
29
+ it "raises NotFoundError" do
30
30
  stub_request(:get, %r[/v1]).
31
31
  to_return(read_fixture("domains_zones/notfound-domain.http"))
32
32
 
33
33
  expect {
34
34
  subject.zone("example.com")
35
- }.to raise_error(Dnsimple::RecordNotFound)
35
+ }.to raise_error(Dnsimple::NotFoundError)
36
36
  end
37
37
  end
38
38
  end
@@ -5,9 +5,9 @@ describe Dnsimple::Client, ".name_servers" do
5
5
  subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").name_servers }
6
6
 
7
7
 
8
- describe "#list" do
8
+ describe "#name_servers" do
9
9
  before do
10
- stub_request(:get, %r[/v1/domains/.+/name_servers]).
10
+ stub_request(:get, %r[/v1/domains/.+/name_servers$]).
11
11
  to_return(read_fixture("nameservers/list/success.http"))
12
12
  end
13
13
 
@@ -19,24 +19,24 @@ describe Dnsimple::Client, ".name_servers" do
19
19
  end
20
20
 
21
21
  it "returns the name servers" do
22
- expect(subject.list("example.com")).to eq(%w( ns1.dnsimple.com ns2.dnsimple.com ))
22
+ expect(subject.name_servers("example.com")).to eq(%w( ns1.dnsimple.com ns2.dnsimple.com ))
23
23
  end
24
24
 
25
25
  context "when something does not exist" do
26
- it "raises RecordNotFound" do
26
+ it "raises NotFoundError" do
27
27
  stub_request(:get, %r[/v1]).
28
28
  to_return(read_fixture("nameservers/notfound-domain.http"))
29
29
 
30
30
  expect {
31
- subject.list("example.com")
32
- }.to raise_error(Dnsimple::RecordNotFound)
31
+ subject.name_servers("example.com")
32
+ }.to raise_error(Dnsimple::NotFoundError)
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
37
  describe "#change" do
38
38
  before do
39
- stub_request(:post, %r[/v1/domains/.+/name_servers]).
39
+ stub_request(:post, %r[/v1/domains/.+/name_servers$]).
40
40
  to_return(read_fixture("nameservers/change/success.http"))
41
41
  end
42
42
 
@@ -53,13 +53,13 @@ describe Dnsimple::Client, ".name_servers" do
53
53
  end
54
54
 
55
55
  context "when something does not exist" do
56
- it "raises RecordNotFound" do
56
+ it "raises NotFoundError" do
57
57
  stub_request(:post, %r[/v1]).
58
58
  to_return(read_fixture("nameservers/notfound-domain.http"))
59
59
 
60
60
  expect {
61
61
  subject.change("example.com", %w())
62
- }.to raise_error(Dnsimple::RecordNotFound)
62
+ }.to raise_error(Dnsimple::NotFoundError)
63
63
  end
64
64
  end
65
65
  end
@@ -86,13 +86,13 @@ describe Dnsimple::Client, ".name_servers" do
86
86
  end
87
87
 
88
88
  context "when the domain does not exist" do
89
- it "raises RecordNotFound" do
89
+ it "raises NotFoundError" do
90
90
  stub_request(:post, %r[/v1]).
91
91
  to_return(read_fixture("nameservers/notfound-domain.http"))
92
92
 
93
93
  expect {
94
94
  subject.register("example.com", "ns1.example.com", "127.0.0.1")
95
- }.to raise_error(Dnsimple::RecordNotFound)
95
+ }.to raise_error(Dnsimple::NotFoundError)
96
96
  end
97
97
  end
98
98
  end
@@ -117,13 +117,13 @@ describe Dnsimple::Client, ".name_servers" do
117
117
  end
118
118
 
119
119
  context "when the domain does not exist" do
120
- it "raises RecordNotFound" do
120
+ it "raises NotFoundError" do
121
121
  stub_request(:delete, %r[/v1]).
122
122
  to_return(read_fixture("nameservers/notfound-domain.http"))
123
123
 
124
124
  expect {
125
125
  subject.deregister("example.com", "ns1.example.com")
126
- }.to raise_error(Dnsimple::RecordNotFound)
126
+ }.to raise_error(Dnsimple::NotFoundError)
127
127
  end
128
128
  end
129
129
  end
@@ -24,8 +24,50 @@ describe Dnsimple::Client, ".registrar" do
24
24
  to_return(read_fixture("registrar/check/registered.http"))
25
25
  end
26
26
 
27
- it "returns available" do
28
- expect(subject.check("example.com")).to eq("registered")
27
+ it "returns the result" do
28
+ result = subject.check("example.com")
29
+
30
+ expect(result).to be_a(Hash)
31
+ expect(result['status']).to eq("unavailable")
32
+ end
33
+ end
34
+
35
+ context "the domain is available" do
36
+ before do
37
+ stub_request(:get, %r[/v1/domains/.+/check$]).
38
+ to_return(read_fixture("registrar/check/available.http"))
39
+ end
40
+
41
+ it "returns the result" do
42
+ result = subject.check("example.com")
43
+
44
+ expect(result).to be_a(Hash)
45
+ expect(result['status']).to eq("available")
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#available?" do
51
+ before do
52
+ stub_request(:get, %r[/v1/domains/.+/check$]).
53
+ to_return(read_fixture("registrar/check/registered.http"))
54
+ end
55
+
56
+ it "builds the correct request" do
57
+ subject.check("example.com")
58
+
59
+ expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/check").
60
+ with(headers: { 'Accept' => 'application/json' })
61
+ end
62
+
63
+ context "the domain is registered" do
64
+ before do
65
+ stub_request(:get, %r[/v1/domains/.+/check$]).
66
+ to_return(read_fixture("registrar/check/registered.http"))
67
+ end
68
+
69
+ it "returns false" do
70
+ expect(subject.available?("example.com")).to be_falsey
29
71
  end
30
72
  end
31
73
 
@@ -35,8 +77,8 @@ describe Dnsimple::Client, ".registrar" do
35
77
  to_return(read_fixture("registrar/check/available.http"))
36
78
  end
37
79
 
38
- it "returns available" do
39
- expect(subject.check("example.com")).to eq("available")
80
+ it "returns true" do
81
+ expect(subject.available?("example.com")).to be_truthy
40
82
  end
41
83
  end
42
84
  end
@@ -84,13 +126,13 @@ describe Dnsimple::Client, ".registrar" do
84
126
  end
85
127
 
86
128
  context "when something does not exist" do
87
- it "raises RecordNotFound" do
129
+ it "raises NotFoundError" do
88
130
  stub_request(:post, %r[/v1]).
89
131
  to_return(read_fixture("domains/notfound.http"))
90
132
 
91
133
  expect {
92
134
  subject.renew("example.com")
93
- }.to raise_error(Dnsimple::RecordNotFound)
135
+ }.to raise_error(Dnsimple::NotFoundError)
94
136
  end
95
137
  end
96
138
  end
@@ -5,21 +5,21 @@ describe Dnsimple::Client, ".services" do
5
5
  subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").services }
6
6
 
7
7
 
8
- describe "#list" do
8
+ describe "#services" do
9
9
  before do
10
10
  stub_request(:get, %r[/v1/services$]).
11
- to_return(read_fixture("services/index/success.http"))
11
+ to_return(read_fixture("services/list/success.http"))
12
12
  end
13
13
 
14
14
  it "builds the correct request" do
15
- subject.list
15
+ subject.services
16
16
 
17
17
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/services").
18
18
  with(headers: { 'Accept' => 'application/json' })
19
19
  end
20
20
 
21
21
  it "returns the services" do
22
- results = subject.list
22
+ results = subject.services
23
23
 
24
24
  expect(results).to be_a(Array)
25
25
  expect(results.size).to eq(3)
@@ -31,21 +31,21 @@ describe Dnsimple::Client, ".services" do
31
31
  end
32
32
  end
33
33
 
34
- describe "#find" do
34
+ describe "#service" do
35
35
  before do
36
36
  stub_request(:get, %r[/v1/services/.+$]).
37
- to_return(read_fixture("services/show/success.http"))
37
+ to_return(read_fixture("services/get/success.http"))
38
38
  end
39
39
 
40
40
  it "builds the correct request" do
41
- subject.find(1)
41
+ subject.service(1)
42
42
 
43
43
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/services/1").
44
44
  with(headers: { 'Accept' => 'application/json' })
45
45
  end
46
46
 
47
47
  it "returns the service" do
48
- result = subject.find(1)
48
+ result = subject.service(1)
49
49
 
50
50
  expect(result).to be_a(Dnsimple::Struct::Service)
51
51
  expect(result.id).to eq(1)
@@ -55,13 +55,13 @@ describe Dnsimple::Client, ".services" do
55
55
  end
56
56
 
57
57
  context "when something does not exist" do
58
- it "raises RecordNotFound" do
58
+ it "raises NotFoundError" do
59
59
  stub_request(:get, %r[/v1]).
60
60
  to_return(read_fixture("services/notfound.http"))
61
61
 
62
62
  expect {
63
- subject.find(1)
64
- }.to raise_error(Dnsimple::RecordNotFound)
63
+ subject.service(1)
64
+ }.to raise_error(Dnsimple::NotFoundError)
65
65
  end
66
66
  end
67
67
  end
@@ -5,21 +5,21 @@ describe Dnsimple::Client, ".templates / records" do
5
5
  subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").templates }
6
6
 
7
7
 
8
- describe "#list_records" do
8
+ describe "#records" do
9
9
  before do
10
10
  stub_request(:get, %r[/v1/templates/.+/records$]).
11
- to_return(read_fixture("templates_records/index/success.http"))
11
+ to_return(read_fixture("templates_records/list/success.http"))
12
12
  end
13
13
 
14
14
  it "builds the correct request" do
15
- subject.list_records(1)
15
+ subject.records(1)
16
16
 
17
17
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates/1/records").
18
18
  with(headers: { 'Accept' => 'application/json' })
19
19
  end
20
20
 
21
21
  it "returns the template records" do
22
- results = subject.list_records(1)
22
+ results = subject.records(1)
23
23
 
24
24
  expect(results).to be_a(Array)
25
25
  expect(results.size).to eq(2)
@@ -53,32 +53,32 @@ describe Dnsimple::Client, ".templates / records" do
53
53
  end
54
54
 
55
55
  context "when something does not exist" do
56
- it "raises RecordNotFound" do
56
+ it "raises NotFoundError" do
57
57
  stub_request(:post, %r[/v1]).
58
58
  to_return(read_fixture("templates_records/notfound.http"))
59
59
 
60
60
  expect {
61
61
  subject.create_record(1, { name: "", record_type: "", content: "" })
62
- }.to raise_error(Dnsimple::RecordNotFound)
62
+ }.to raise_error(Dnsimple::NotFoundError)
63
63
  end
64
64
  end
65
65
  end
66
66
 
67
- describe "#find_record" do
67
+ describe "#record" do
68
68
  before do
69
69
  stub_request(:get, %r[/v1/templates/.+/records/.+$]).
70
- to_return(read_fixture("templates_records/show/success.http"))
70
+ to_return(read_fixture("templates_records/get/success.http"))
71
71
  end
72
72
 
73
73
  it "builds the correct request" do
74
- subject.find_record(1, 2)
74
+ subject.record(1, 2)
75
75
 
76
76
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates/1/records/2").
77
77
  with(headers: { 'Accept' => 'application/json' })
78
78
  end
79
79
 
80
80
  it "returns the record" do
81
- result = subject.find_record(1, 2)
81
+ result = subject.record(1, 2)
82
82
 
83
83
  expect(result).to be_a(Dnsimple::Struct::TemplateRecord)
84
84
  expect(result.id).to eq(8868)
@@ -93,13 +93,13 @@ describe Dnsimple::Client, ".templates / records" do
93
93
  end
94
94
 
95
95
  context "when something does not exist" do
96
- it "raises RecordNotFound" do
96
+ it "raises NotFoundError" do
97
97
  stub_request(:get, %r[/v1]).
98
98
  to_return(read_fixture("templates_records/notfound.http"))
99
99
 
100
100
  expect {
101
- subject.find_record(1, 2)
102
- }.to raise_error(Dnsimple::RecordNotFound)
101
+ subject.record(1, 2)
102
+ }.to raise_error(Dnsimple::NotFoundError)
103
103
  end
104
104
  end
105
105
  end
@@ -126,13 +126,13 @@ describe Dnsimple::Client, ".templates / records" do
126
126
  end
127
127
 
128
128
  context "when something does not exist" do
129
- it "raises RecordNotFound" do
129
+ it "raises NotFoundError" do
130
130
  stub_request(:put, %r[/v1]).
131
131
  to_return(read_fixture("templates_records/notfound.http"))
132
132
 
133
133
  expect {
134
134
  subject.update_record(1, 2, {})
135
- }.to raise_error(Dnsimple::RecordNotFound)
135
+ }.to raise_error(Dnsimple::NotFoundError)
136
136
  end
137
137
  end
138
138
  end
@@ -166,13 +166,13 @@ describe Dnsimple::Client, ".templates / records" do
166
166
  end
167
167
 
168
168
  context "when something does not exist" do
169
- it "raises RecordNotFound" do
169
+ it "raises NotFoundError" do
170
170
  stub_request(:delete, %r[/v1]).
171
171
  to_return(read_fixture("templates_records/notfound.http"))
172
172
 
173
173
  expect {
174
174
  subject.delete_record(1, 2)
175
- }.to raise_error(Dnsimple::RecordNotFound)
175
+ }.to raise_error(Dnsimple::NotFoundError)
176
176
  end
177
177
  end
178
178
  end
@@ -5,21 +5,21 @@ describe Dnsimple::Client, ".templates" do
5
5
  subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").templates }
6
6
 
7
7
 
8
- describe "#list" do
8
+ describe "#templates" do
9
9
  before do
10
10
  stub_request(:get, %r[/v1/templates$]).
11
- to_return(read_fixture("templates/index/success.http"))
11
+ to_return(read_fixture("templates/list/success.http"))
12
12
  end
13
13
 
14
14
  it "builds the correct request" do
15
- subject.list
15
+ subject.templates
16
16
 
17
17
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates").
18
18
  with(headers: { 'Accept' => 'application/json' })
19
19
  end
20
20
 
21
21
  it "returns the templates" do
22
- results = subject.list
22
+ results = subject.templates
23
23
 
24
24
  expect(results).to be_a(Array)
25
25
  expect(results.size).to eq(1)
@@ -55,21 +55,21 @@ describe Dnsimple::Client, ".templates" do
55
55
  end
56
56
  end
57
57
 
58
- describe "#find" do
58
+ describe "#template" do
59
59
  before do
60
60
  stub_request(:get, %r[/v1/templates/.+$]).
61
- to_return(read_fixture("templates/show/success.http"))
61
+ to_return(read_fixture("templates/get/success.http"))
62
62
  end
63
63
 
64
64
  it "builds the correct request" do
65
- subject.find(1)
65
+ subject.template(1)
66
66
 
67
67
  expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates/1").
68
68
  with(headers: { 'Accept' => 'application/json' })
69
69
  end
70
70
 
71
71
  it "returns the template" do
72
- result = subject.find(1)
72
+ result = subject.template(1)
73
73
 
74
74
  expect(result).to be_a(Dnsimple::Struct::Template)
75
75
  expect(result.id).to eq(2651)
@@ -79,13 +79,13 @@ describe Dnsimple::Client, ".templates" do
79
79
  end
80
80
 
81
81
  context "when something does not exist" do
82
- it "raises RecordNotFound" do
82
+ it "raises NotFoundError" do
83
83
  stub_request(:get, %r[/v1]).
84
84
  to_return(read_fixture("templates/notfound.http"))
85
85
 
86
86
  expect {
87
- subject.find(1)
88
- }.to raise_error(Dnsimple::RecordNotFound)
87
+ subject.template(1)
88
+ }.to raise_error(Dnsimple::NotFoundError)
89
89
  end
90
90
  end
91
91
  end
@@ -112,13 +112,13 @@ describe Dnsimple::Client, ".templates" do
112
112
  end
113
113
 
114
114
  context "when something does not exist" do
115
- it "raises RecordNotFound" do
115
+ it "raises NotFoundError" do
116
116
  stub_request(:put, %r[/v1]).
117
117
  to_return(read_fixture("templates/notfound.http"))
118
118
 
119
119
  expect {
120
120
  subject.update(1, {})
121
- }.to raise_error(Dnsimple::RecordNotFound)
121
+ }.to raise_error(Dnsimple::NotFoundError)
122
122
  end
123
123
  end
124
124
  end
@@ -152,13 +152,13 @@ describe Dnsimple::Client, ".templates" do
152
152
  end
153
153
 
154
154
  context "when something does not exist" do
155
- it "raises RecordNotFound" do
155
+ it "raises NotFoundError" do
156
156
  stub_request(:delete, %r[/v1]).
157
157
  to_return(read_fixture("templates/notfound.http"))
158
158
 
159
159
  expect {
160
160
  subject.delete(1)
161
- }.to raise_error(Dnsimple::RecordNotFound)
161
+ }.to raise_error(Dnsimple::NotFoundError)
162
162
  end
163
163
  end
164
164
  end
@@ -184,13 +184,13 @@ describe Dnsimple::Client, ".templates" do
184
184
  end
185
185
 
186
186
  context "when something does not exist" do
187
- it "raises RecordNotFound" do
187
+ it "raises NotFoundError" do
188
188
  stub_request(:post, %r[/v1]).
189
189
  to_return(read_fixture("templates/notfound.http"))
190
190
 
191
191
  expect {
192
192
  subject.apply(1, 2)
193
- }.to raise_error(Dnsimple::RecordNotFound)
193
+ }.to raise_error(Dnsimple::NotFoundError)
194
194
  end
195
195
  end
196
196
  end