From 1808ddbe5708366f618485eb8650361c22033e08 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 17:00:15 +0100 Subject: [PATCH 01/11] Add the DomainRecord result type --- lib/dnsimple/struct/domain_record.rb | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/dnsimple/struct/domain_record.rb diff --git a/lib/dnsimple/struct/domain_record.rb b/lib/dnsimple/struct/domain_record.rb new file mode 100644 index 00000000..8fdbd6ef --- /dev/null +++ b/lib/dnsimple/struct/domain_record.rb @@ -0,0 +1,40 @@ +module Dnsimple + module Struct + + class DomainRecord < Base + # @return [Fixnum] The record ID in DNSimple. + attr_accessor :id + + # @return [Fixnum] The associated domain ID. + attr_accessor :domain_id + + # @return [Fixnum] The ID of the parent record, if this record is dependent on another record. + attr_accessor :parent_id + + # @return [String] The type of record, in uppercase. + attr_accessor :type + + # @return [String] The record name (without the domain name). + attr_accessor :name + + # @return [String] The plain-text record content. + attr_accessor :content + + # @return [Fixnum] The TTL value. + attr_accessor :ttl + + # @return [Fixnum] The priority value, if the type of record accepts a priority. + attr_accessor :priority + + # @return [Bool] True if this is a system record created by DNSimple. System records are read-only. + attr_accessor :system_record + + # @return [String] When the domain was created in DNSimple. + attr_accessor :created_at + + # @return [String] When the domain was last updated in DNSimple. + attr_accessor :updated_at + end + + end +end From e9846f86f52e42cd3e787990010f02698be946aa Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 17:01:12 +0100 Subject: [PATCH 02/11] It's a zone Record. Let's just call it record for now --- lib/dnsimple/struct/{domain_record.rb => record.rb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lib/dnsimple/struct/{domain_record.rb => record.rb} (97%) diff --git a/lib/dnsimple/struct/domain_record.rb b/lib/dnsimple/struct/record.rb similarity index 97% rename from lib/dnsimple/struct/domain_record.rb rename to lib/dnsimple/struct/record.rb index 8fdbd6ef..2710544d 100644 --- a/lib/dnsimple/struct/domain_record.rb +++ b/lib/dnsimple/struct/record.rb @@ -1,7 +1,7 @@ module Dnsimple module Struct - class DomainRecord < Base + class Record < Base # @return [Fixnum] The record ID in DNSimple. attr_accessor :id From c0e7a1ec3a94155243075308dddae4dc8e8a73f4 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 17:04:59 +0100 Subject: [PATCH 03/11] Add client.zones -> record service --- lib/dnsimple/client/clients.rb | 12 ++++++++++++ lib/dnsimple/client/zones_records.rb | 6 ++++++ spec/dnsimple/client/zones_records_spec.rb | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 lib/dnsimple/client/zones_records.rb create mode 100644 spec/dnsimple/client/zones_records_spec.rb diff --git a/lib/dnsimple/client/clients.rb b/lib/dnsimple/client/clients.rb index 832bd292..97239396 100644 --- a/lib/dnsimple/client/clients.rb +++ b/lib/dnsimple/client/clients.rb @@ -11,6 +11,11 @@ def misc @services[:misc] ||= Client::MiscService.new(self) end + # @return [Dnsimple::Client::ZonesService] The zone-related API proxy. + def zones + @services[:zones] ||= Client::ZonesService.new(self) + end + class ClientService < ::Struct.new(:client) @@ -56,5 +61,12 @@ class MiscService < ClientService include Client::Misc end + + require_relative 'zones_records' + + class ZonesService < ClientService + include Client::ZonesRecords + end + end end diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb new file mode 100644 index 00000000..a78d4a50 --- /dev/null +++ b/lib/dnsimple/client/zones_records.rb @@ -0,0 +1,6 @@ +module Dnsimple + class Client + module ZonesRecords + end + end +end diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb new file mode 100644 index 00000000..66602925 --- /dev/null +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe Dnsimple::Client, ".zones" do + + subject { described_class.new(api_endpoint: "https://api.dnsimple.test", access_token: "a1b2c3").zones } + +end From 8008ef96996b1b8fa17462c44915df015b5299ff Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 17:47:01 +0100 Subject: [PATCH 04/11] Add listZoneRecords() and allZoneRecords() --- lib/dnsimple/client/domains.rb | 4 +- lib/dnsimple/client/zones_records.rb | 44 +++++++++++++ lib/dnsimple/struct.rb | 1 + spec/dnsimple/client/domains_spec.rb | 10 ++- spec/dnsimple/client/zones_records_spec.rb | 63 +++++++++++++++++++ spec/files/{domains => }/notfound-domain.http | 22 +++---- spec/files/notfound-zone.http | 12 ++++ spec/files/zones/records/success.http | 17 +++++ 8 files changed, 158 insertions(+), 15 deletions(-) rename spec/files/{domains => }/notfound-domain.http (87%) create mode 100644 spec/files/notfound-zone.http create mode 100644 spec/files/zones/records/success.http diff --git a/lib/dnsimple/client/domains.rb b/lib/dnsimple/client/domains.rb index 1d15ecb7..fc36c1fa 100644 --- a/lib/dnsimple/client/domains.rb +++ b/lib/dnsimple/client/domains.rb @@ -8,10 +8,10 @@ module Domains # @see #all_domains # # @example List domains in the first page - # client.domains(1010) + # client.domains.list(1010) # # @example List domains, provide a specific page - # client.domains(1010, query: { page: 2 }) + # client.domains.list(1010, query: { page: 2 }) # # @param [Fixnum] account_id the account ID # @param [Hash] options the filtering and sorting option diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb index a78d4a50..cc20b000 100644 --- a/lib/dnsimple/client/zones_records.rb +++ b/lib/dnsimple/client/zones_records.rb @@ -1,6 +1,50 @@ module Dnsimple class Client module ZonesRecords + + # Lists the zone records in the account. + # + # @see https://developer.dnsimple.com/v2/zones/records/#list + # @see #all_records + # + # @example List records for the zone "example.com" in the first page + # client.zones.records(1010, "example.com") + # + # @example List records for the zone "example.com", provide a specific page + # client.zones.records(1010, "example.com", query: { page: 2 }) + # + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard + # @param [String] zone_id the zone name + # @param [Hash] options the filtering and sorting option + # @return [Dnsimple::PaginatedResponse] + # @raise [Dnsimple::RequestError] + def records(account_id, zone_id, options = {}) + response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), options) + + Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Record.new(r) }) + end + alias :list_records :records + + # Lists ALL the zone records in the account. + # + # This method is similar to {#records}, but instead of returning the results of a specific page + # it iterates all the pages and returns the entire collection. + # + # Please use this method carefully, as fetching the entire collection will increase the number of requests + # you send to the API server and you may eventually risk to hit the throttle limit. + # + # @see https://developer.dnsimple.com/v2/zones/records/#list + # @see #records + # + # @param [Fixnum] account_id the account ID + # @param [String] zone_id the zone name + # @param [Hash] options the filtering and sorting option + # @return [Dnsimple::CollectionResponse] + # @raise [Dnsimple::RequestError] + def all_records(account_id, zone_id, options = {}) + paginate(:records, account_id, zone_id, options) + end + end end end diff --git a/lib/dnsimple/struct.rb b/lib/dnsimple/struct.rb index feb21bfe..bfa03f27 100644 --- a/lib/dnsimple/struct.rb +++ b/lib/dnsimple/struct.rb @@ -15,4 +15,5 @@ def initialize(attributes = {}) require_relative 'struct/account' require_relative 'struct/domain' +require_relative 'struct/record' require_relative 'struct/user' diff --git a/spec/dnsimple/client/domains_spec.rb b/spec/dnsimple/client/domains_spec.rb index 2d25e903..11da75f9 100644 --- a/spec/dnsimple/client/domains_spec.rb +++ b/spec/dnsimple/client/domains_spec.rb @@ -26,6 +26,12 @@ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=2") end + it "supports extra request options" do + subject.domains(account_id, query: { foo: "bar" }) + + expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?foo=bar") + end + it "returns the domains" do response = subject.domains(account_id) @@ -123,7 +129,7 @@ context "when something does not exist" do it "raises NotFoundError" do stub_request(:get, %r[/v2]) - .to_return(read_fixture("domains/notfound-domain.http")) + .to_return(read_fixture("notfound-domain.http")) expect { subject.domain(account_id, "example.com") @@ -158,7 +164,7 @@ context "when something does not exist" do it "raises NotFoundError" do stub_request(:delete, %r[/v2]) - .to_return(read_fixture("domains/notfound-domain.http")) + .to_return(read_fixture("notfound-domain.http")) expect { subject.delete_domain(account_id, "example.com") diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index 66602925..d3a33eaf 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -4,4 +4,67 @@ subject { described_class.new(api_endpoint: "https://api.dnsimple.test", access_token: "a1b2c3").zones } + + describe "#records" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + before do + stub_request(:get, %r[/v2/#{account_id}/zones/#{zone_id}/records]) + .to_return(read_fixture("zones/records/success.http")) + end + + it "builds the correct request" do + subject.records(account_id, zone_id) + + expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records") + .with(headers: { 'Accept' => 'application/json' }) + end + + it "supports pagination" do + subject.records(account_id, zone_id, query: { page: 2 }) + + expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?page=2") + end + + it "supports extra request options" do + subject.records(account_id, zone_id, query: { foo: "bar" }) + + expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records?foo=bar") + end + + it "returns the records" do + response = subject.records(account_id, zone_id) + + expect(response).to be_a(Dnsimple::PaginatedResponse) + expect(response.data).to be_a(Array) + expect(response.data.size).to eq(5) + + response.data.each do |result| + expect(result).to be_a(Dnsimple::Struct::Record) + expect(result.id).to be_a(Fixnum) + end + end + + it "exposes the pagination information" do + response = subject.records(account_id, zone_id) + + expect(response.respond_to?(:page)).to be_truthy + expect(response.page).to eq(1) + expect(response.per_page).to be_a(Fixnum) + expect(response.total_entries).to be_a(Fixnum) + expect(response.total_pages).to be_a(Fixnum) + end + end + + describe "#all_records" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + it "delegates to client.paginate" do + expect(subject).to receive(:paginate).with(:records, account_id, zone_id, { foo: "bar" }) + subject.all_records(account_id, zone_id, { foo: "bar" }) + end + end + end diff --git a/spec/files/domains/notfound-domain.http b/spec/files/notfound-domain.http similarity index 87% rename from spec/files/domains/notfound-domain.http rename to spec/files/notfound-domain.http index ea415de6..5acaf7bc 100644 --- a/spec/files/domains/notfound-domain.http +++ b/spec/files/notfound-domain.http @@ -1,12 +1,12 @@ -HTTP/1.1 404 Not Found -Server: nginx -Date: Wed, 16 Dec 2015 22:07:20 GMT -Content-Type: application/json; charset=utf-8 -Transfer-Encoding: chunked -Connection: keep-alive -Strict-Transport-Security: max-age=31536000 -Cache-Control: no-cache -X-Request-Id: bc587ea7-bcd5-4c10-a940-a9b4c8339824 -X-Runtime: 0.059966 - +HTTP/1.1 404 Not Found +Server: nginx +Date: Wed, 16 Dec 2015 22:07:20 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Strict-Transport-Security: max-age=31536000 +Cache-Control: no-cache +X-Request-Id: bc587ea7-bcd5-4c10-a940-a9b4c8339824 +X-Runtime: 0.059966 + {"message":"Domain `0' not found"} \ No newline at end of file diff --git a/spec/files/notfound-zone.http b/spec/files/notfound-zone.http new file mode 100644 index 00000000..84dd9af1 --- /dev/null +++ b/spec/files/notfound-zone.http @@ -0,0 +1,12 @@ +HTTP/1.1 500 Internal Server Error +Server: nginx +Date: Thu, 07 Jan 2016 16:35:37 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 500 Internal Server Error +Cache-Control: no-cache +X-Request-Id: 0de115b1-2143-44e5-b117-c7f9c51ea2ff +X-Runtime: 0.022304 + +{"message":"Internal Server Error"} \ No newline at end of file diff --git a/spec/files/zones/records/success.http b/spec/files/zones/records/success.http new file mode 100644 index 00000000..31fc420a --- /dev/null +++ b/spec/files/zones/records/success.http @@ -0,0 +1,17 @@ +HTTP/1.1 200 OK +Server: nginx +Date: Thu, 07 Jan 2016 16:33:47 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 200 OK +X-RateLimit-Limit: 4000 +X-RateLimit-Remaining: 3994 +X-RateLimit-Reset: 1452184426 +ETag: W/"1ae3e2e65dbcc2c2a7237e3e564129dd" +Cache-Control: max-age=0, private, must-revalidate +X-Request-Id: 9b361b57-43e2-47df-9f00-e7c252bc4d41 +X-Runtime: 0.107990 +Strict-Transport-Security: max-age=31536000 + +{"data":[{"id":64779,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300","ttl":3600,"priority":null,"type":"SOA","system_record":true,"created_at":"2016-01-07T16:30:05.379Z","updated_at":"2016-01-07T16:30:05.379Z"},{"id":64780,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.422Z","updated_at":"2016-01-07T16:30:05.422Z"},{"id":64781,"domain_id":5841,"parent_id":null,"name":"","content":"ns2.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.433Z","updated_at":"2016-01-07T16:30:05.433Z"},{"id":64782,"domain_id":5841,"parent_id":null,"name":"","content":"ns3.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.445Z","updated_at":"2016-01-07T16:30:05.445Z"},{"id":64783,"domain_id":5841,"parent_id":null,"name":"","content":"ns4.dnsimple.com","ttl":3600,"priority":null,"type":"NS","system_record":true,"created_at":"2016-01-07T16:30:05.457Z","updated_at":"2016-01-07T16:30:05.457Z"}],"pagination":{"current_page":1,"per_page":30,"total_entries":5,"total_pages":1}} \ No newline at end of file From dde875a6dd8e41023024efa52f9492568e7c31ea Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 18:13:23 +0100 Subject: [PATCH 05/11] Add getZoneRecord() --- lib/dnsimple/client/zones_records.rb | 22 ++++++- spec/dnsimple/client/zones_records_spec.rb | 69 ++++++++++++++++++++++ spec/files/notfound-record.http | 12 ++++ spec/files/zones/record/success.http | 17 ++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 spec/files/notfound-record.http create mode 100644 spec/files/zones/record/success.http diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb index cc20b000..2d369c3c 100644 --- a/lib/dnsimple/client/zones_records.rb +++ b/lib/dnsimple/client/zones_records.rb @@ -17,6 +17,7 @@ module ZonesRecords # @param [String] zone_id the zone name # @param [Hash] options the filtering and sorting option # @return [Dnsimple::PaginatedResponse] + # # @raise [Dnsimple::RequestError] def records(account_id, zone_id, options = {}) response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), options) @@ -36,15 +37,34 @@ def records(account_id, zone_id, options = {}) # @see https://developer.dnsimple.com/v2/zones/records/#list # @see #records # - # @param [Fixnum] account_id the account ID + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard # @param [String] zone_id the zone name # @param [Hash] options the filtering and sorting option # @return [Dnsimple::CollectionResponse] + # # @raise [Dnsimple::RequestError] def all_records(account_id, zone_id, options = {}) paginate(:records, account_id, zone_id, options) end + # Gets a zone record from the account. + # + # @see https://developer.dnsimple.com/v2/zones/records/#get + # + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard + # @param [String] zone_id the zone name + # @param [Fixnum] record_id the record ID + # @param [Hash] options + # @return [Dnsimple::Response] + # + # @raise [Dnsimple::NotFoundError] + # @raise [Dnsimple::RequestError] + def record(account_id, zone_id, record_id, options = {}) + response = client.get(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), options) + + Dnsimple::Response.new(response, Struct::Record.new(response["data"])) + end + end end end diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index d3a33eaf..051157bb 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -55,6 +55,17 @@ expect(response.total_entries).to be_a(Fixnum) expect(response.total_pages).to be_a(Fixnum) end + + # context "when the zone does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-zone.http")) + # + # expect { + # subject.domain(account_id, zone_id) + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end end describe "#all_records" do @@ -67,4 +78,62 @@ end end + describe "#record" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + before do + stub_request(:get, %r[/v2/#{account_id}/zones/#{zone_id}/records/.+$]) + .to_return(read_fixture("zones/record/success.http")) + end + + it "builds the correct request" do + subject.record(account_id, zone_id, record = "3") + + expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record}") + .with(headers: { 'Accept' => 'application/json' }) + end + + it "returns the record" do + response = subject.record(account_id, zone_id, "3") + expect(response).to be_a(Dnsimple::Response) + + result = response.data + expect(result).to be_a(Dnsimple::Struct::Record) + expect(result.id).to eq(64779) + expect(result.domain_id).to eq(5841) + expect(result.parent_id).to eq(nil) + expect(result.type).to eq("SOA") + expect(result.name).to eq("") + expect(result.content).to eq("ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300") + expect(result.ttl).to eq(3600) + expect(result.priority).to eq(nil) + expect(result.system_record).to eq(true) + expect(result.created_at).to eq("2016-01-07T16:30:05.379Z") + expect(result.updated_at).to eq("2016-01-07T16:30:05.379Z") + end + + # context "when the zone does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-zone.http")) + # + # expect { + # subject.domain(account_id, zone_id, "0") + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + + # context "when the record does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-record.http")) + # + # expect { + # subject.domain(account_id, zone_id, "0") + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + end + end diff --git a/spec/files/notfound-record.http b/spec/files/notfound-record.http new file mode 100644 index 00000000..e856cd91 --- /dev/null +++ b/spec/files/notfound-record.http @@ -0,0 +1,12 @@ +HTTP/1.1 500 Internal Server Error +Server: nginx +Date: Thu, 07 Jan 2016 17:06:11 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 500 Internal Server Error +Cache-Control: no-cache +X-Request-Id: 9ab528c2-affa-413b-8c6f-fc5a865c418f +X-Runtime: 0.037865 + +{"message":"Internal Server Error"} \ No newline at end of file diff --git a/spec/files/zones/record/success.http b/spec/files/zones/record/success.http new file mode 100644 index 00000000..f4c67a6c --- /dev/null +++ b/spec/files/zones/record/success.http @@ -0,0 +1,17 @@ +HTTP/1.1 200 OK +Server: nginx +Date: Thu, 07 Jan 2016 17:05:54 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 200 OK +X-RateLimit-Limit: 4000 +X-RateLimit-Remaining: 3992 +X-RateLimit-Reset: 1452186353 +ETag: W/"f47d46682d197eb264985cde712813c2" +Cache-Control: max-age=0, private, must-revalidate +X-Request-Id: 6494db54-42b0-4281-9f96-3634c5295c0e +X-Runtime: 0.128238 +Strict-Transport-Security: max-age=31536000 + +{"data":{"id":64779,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300","ttl":3600,"priority":null,"type":"SOA","system_record":true,"created_at":"2016-01-07T16:30:05.379Z","updated_at":"2016-01-07T16:30:05.379Z"}} \ No newline at end of file From 34803b42116307981d639efbd1b9ad34d36fb9c0 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 18:13:31 +0100 Subject: [PATCH 06/11] Cleanup docs --- lib/dnsimple/client/domains.rb | 14 ++++++++------ spec/dnsimple/client/domains_spec.rb | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/dnsimple/client/domains.rb b/lib/dnsimple/client/domains.rb index fc36c1fa..dd59c440 100644 --- a/lib/dnsimple/client/domains.rb +++ b/lib/dnsimple/client/domains.rb @@ -16,6 +16,7 @@ module Domains # @param [Fixnum] account_id the account ID # @param [Hash] options the filtering and sorting option # @return [Dnsimple::PaginatedResponse] + # # @raise [Dnsimple::RequestError] def domains(account_id, options = {}) response = client.get(Client.versioned("/%s/domains" % [account_id]), options) @@ -39,6 +40,7 @@ def domains(account_id, options = {}) # @param [Fixnum] account_id the account ID # @param [Hash] options the filtering and sorting option # @return [Dnsimple::CollectionResponse] + # # @raise [Dnsimple::RequestError] def all_domains(account_id, options = {}) paginate(:domains, account_id, options) @@ -69,14 +71,14 @@ def create_domain(account_id, attributes = {}, options = {}) # @see https://developer.dnsimple.com/v2/domains/#get # # @param [Fixnum] account_id the account ID - # @param [#to_s] domain The domain id or domain name. + # @param [#to_s] domain_id The domain id or domain name. # @param [Hash] options # @return [Dnsimple::Response] # # @raise [Dnsimple::NotFoundError] # @raise [Dnsimple::RequestError] - def domain(account_id, domain, options = {}) - response = client.get(Client.versioned("/%s/domains/%s" % [account_id, domain]), options) + def domain(account_id, domain_id, options = {}) + response = client.get(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), options) Dnsimple::Response.new(response, Struct::Domain.new(response["data"])) end @@ -88,14 +90,14 @@ def domain(account_id, domain, options = {}) # @see https://developer.dnsimple.com/v2/domains/#delete # # @param [Fixnum] account_id the account ID - # @param [#to_s] domain The domain id or domain name. + # @param [#to_s] domain_id The domain id or domain name. # @param [Hash] options # @return [Dnsimple::Response] # # @raise [Dnsimple::NotFoundError] # @raise [Dnsimple::RequestError] - def delete_domain(account_id, domain, options = {}) - response = client.delete(Client.versioned("/%s/domains/%s" % [account_id, domain]), options) + def delete_domain(account_id, domain_id, options = {}) + response = client.delete(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), options) Dnsimple::Response.new(response, nil) end diff --git a/spec/dnsimple/client/domains_spec.rb b/spec/dnsimple/client/domains_spec.rb index 11da75f9..39e0337a 100644 --- a/spec/dnsimple/client/domains_spec.rb +++ b/spec/dnsimple/client/domains_spec.rb @@ -126,7 +126,7 @@ expect(result.updated_at).to eq("2015-12-09T00:20:56.056Z") end - context "when something does not exist" do + context "when the domain does not exist" do it "raises NotFoundError" do stub_request(:get, %r[/v2]) .to_return(read_fixture("notfound-domain.http")) @@ -161,7 +161,7 @@ expect(result).to be_nil end - context "when something does not exist" do + context "when the domain does not exist" do it "raises NotFoundError" do stub_request(:delete, %r[/v2]) .to_return(read_fixture("notfound-domain.http")) From 93e138d7a479db106688a7e39a8ec93fe05a923d Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 18:52:29 +0100 Subject: [PATCH 07/11] Add createZoneRecord() --- lib/dnsimple/client/zones_records.rb | 19 +++++++ spec/dnsimple/client/zones_records_spec.rb | 56 ++++++++++++++++++--- spec/files/zones/create_record/created.http | 17 +++++++ spec/files/zones/record/success.http | 14 +++--- 4 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 spec/files/zones/create_record/created.http diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb index 2d369c3c..84cec9cb 100644 --- a/lib/dnsimple/client/zones_records.rb +++ b/lib/dnsimple/client/zones_records.rb @@ -47,6 +47,25 @@ def all_records(account_id, zone_id, options = {}) paginate(:records, account_id, zone_id, options) end + # Creates a zone record in the account. + # + # @see https://developer.dnsimple.com/v2/zones/records/#create + # + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard + # @param [String] zone_id the zone name + # @param [Hash] attributes + # @param [Hash] options + # @return [Dnsimple::Response] + # + # @raise [Dnsimple::RequestError] + def create_record(account_id, zone_id, attributes = {}, options = {}) + Extra.validate_mandatory_attributes(attributes, [:record_type, :name, :content]) + options = options.merge(attributes) + response = client.post(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), options) + + Dnsimple::Response.new(response, Struct::Record.new(response["data"])) + end + # Gets a zone record from the account. # # @see https://developer.dnsimple.com/v2/zones/records/#get diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index 051157bb..aa980b1d 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -78,6 +78,46 @@ end end + describe "#create_record" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + before do + stub_request(:post, %r[/v2/#{account_id}/zones/#{zone_id}/records$]) + .to_return(read_fixture("zones/create_record/created.http")) + end + + let(:attributes) { { record_type: "A", name: "www", content: "127.0.0.1" } } + + it "builds the correct request" do + subject.create_record(account_id, zone_id, attributes) + + expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records") + .with(body: attributes) + .with(headers: { 'Accept' => 'application/json' }) + end + + it "returns the record" do + response = subject.create_record(account_id, zone_id, attributes) + expect(response).to be_a(Dnsimple::Response) + + result = response.data + expect(result).to be_a(Dnsimple::Struct::Record) + expect(result.id).to be_a(Fixnum) + end + + # context "when the zone does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-zone.http")) + # + # expect { + # subject.domain(account_id, zone_id) + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + end + describe "#record" do let(:account_id) { 1010 } let(:zone_id) { "example.com" } @@ -100,17 +140,17 @@ result = response.data expect(result).to be_a(Dnsimple::Struct::Record) - expect(result.id).to eq(64779) + expect(result.id).to eq(64784) expect(result.domain_id).to eq(5841) expect(result.parent_id).to eq(nil) - expect(result.type).to eq("SOA") - expect(result.name).to eq("") - expect(result.content).to eq("ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300") - expect(result.ttl).to eq(3600) + expect(result.type).to eq("A") + expect(result.name).to eq("www") + expect(result.content).to eq("127.0.0.1") + expect(result.ttl).to eq(600) expect(result.priority).to eq(nil) - expect(result.system_record).to eq(true) - expect(result.created_at).to eq("2016-01-07T16:30:05.379Z") - expect(result.updated_at).to eq("2016-01-07T16:30:05.379Z") + expect(result.system_record).to eq(false) + expect(result.created_at).to eq("2016-01-07T17:45:13.653Z") + expect(result.updated_at).to eq("2016-01-07T17:45:13.653Z") end # context "when the zone does not exist" do diff --git a/spec/files/zones/create_record/created.http b/spec/files/zones/create_record/created.http new file mode 100644 index 00000000..4f065c81 --- /dev/null +++ b/spec/files/zones/create_record/created.http @@ -0,0 +1,17 @@ +HTTP/1.1 201 Created +Server: nginx +Date: Thu, 07 Jan 2016 17:45:13 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 201 Created +X-RateLimit-Limit: 4000 +X-RateLimit-Remaining: 3990 +X-RateLimit-Reset: 1452188712 +ETag: W/"a7ddff4ee5dc28bbebf3d416e8bd0f04" +Cache-Control: max-age=0, private, must-revalidate +X-Request-Id: f96f5034-bf0c-4201-9564-493c162e3cb4 +X-Runtime: 0.099095 +Strict-Transport-Security: max-age=31536000 + +{"data":{"id":64784,"domain_id":5841,"parent_id":null,"name":"www","content":"127.0.0.1","ttl":600,"priority":null,"type":"A","system_record":false,"created_at":"2016-01-07T17:45:13.653Z","updated_at":"2016-01-07T17:45:13.653Z"}} \ No newline at end of file diff --git a/spec/files/zones/record/success.http b/spec/files/zones/record/success.http index f4c67a6c..fd05ebd4 100644 --- a/spec/files/zones/record/success.http +++ b/spec/files/zones/record/success.http @@ -1,17 +1,17 @@ HTTP/1.1 200 OK Server: nginx -Date: Thu, 07 Jan 2016 17:05:54 GMT +Date: Thu, 07 Jan 2016 17:46:19 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Status: 200 OK X-RateLimit-Limit: 4000 -X-RateLimit-Remaining: 3992 -X-RateLimit-Reset: 1452186353 -ETag: W/"f47d46682d197eb264985cde712813c2" +X-RateLimit-Remaining: 3989 +X-RateLimit-Reset: 1452188778 +ETag: W/"a7ddff4ee5dc28bbebf3d416e8bd0f04" Cache-Control: max-age=0, private, must-revalidate -X-Request-Id: 6494db54-42b0-4281-9f96-3634c5295c0e -X-Runtime: 0.128238 +X-Request-Id: 69258cd7-c9e6-4681-aed6-cb5bbdfbb156 +X-Runtime: 0.048748 Strict-Transport-Security: max-age=31536000 -{"data":{"id":64779,"domain_id":5841,"parent_id":null,"name":"","content":"ns1.dnsimple.com admin.dnsimple.com 1452184205 86400 7200 604800 300","ttl":3600,"priority":null,"type":"SOA","system_record":true,"created_at":"2016-01-07T16:30:05.379Z","updated_at":"2016-01-07T16:30:05.379Z"}} \ No newline at end of file +{"data":{"id":64784,"domain_id":5841,"parent_id":null,"name":"www","content":"127.0.0.1","ttl":600,"priority":null,"type":"A","system_record":false,"created_at":"2016-01-07T17:45:13.653Z","updated_at":"2016-01-07T17:45:13.653Z"}} \ No newline at end of file From 294eb9a034af06ed38d9c990201578a875e7a112 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 19:01:39 +0100 Subject: [PATCH 08/11] Add updateZoneRecord() --- lib/dnsimple/client.rb | 9 ++++ lib/dnsimple/client/zones_records.rb | 20 ++++++++ spec/dnsimple/client/zones_records_spec.rb | 57 +++++++++++++++++++-- spec/files/zones/update_record/success.http | 17 ++++++ 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 spec/files/zones/update_record/success.http diff --git a/lib/dnsimple/client.rb b/lib/dnsimple/client.rb index 842a6931..618982b1 100644 --- a/lib/dnsimple/client.rb +++ b/lib/dnsimple/client.rb @@ -94,6 +94,15 @@ def put(path, options = {}) execute :put, path, options end + # Make a HTTP PATCH request. + # + # @param [String] path The path, relative to {#api_endpoint} + # @param [Hash] options Body and header params for request + # @return [HTTParty::Response] + def patch(path, options = {}) + execute :patch, path, options + end + # Make a HTTP DELETE request. # # @param [String] path The path, relative to {#api_endpoint} diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb index 84cec9cb..e6940160 100644 --- a/lib/dnsimple/client/zones_records.rb +++ b/lib/dnsimple/client/zones_records.rb @@ -84,6 +84,26 @@ def record(account_id, zone_id, record_id, options = {}) Dnsimple::Response.new(response, Struct::Record.new(response["data"])) end + # Updates a zone record in the account. + # + # @see https://developer.dnsimple.com/v2/zones/records/#update + # + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard + # @param [String] zone_id the zone name + # @param [Fixnum] record_id the record ID + # @param [Hash] attributes + # @param [Hash] options + # @return [Dnsimple::Response] + # + # @raise [Dnsimple::NotFoundError] + # @raise [Dnsimple::RequestError] + def update_record(account_id, zone_id, record_id, attributes = {}, options = {}) + options = options.merge(attributes) + response = client.patch(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), options) + + Dnsimple::Response.new(response, Struct::Record.new(response["data"])) + end + end end end diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index aa980b1d..eded3adc 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -93,8 +93,8 @@ subject.create_record(account_id, zone_id, attributes) expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records") - .with(body: attributes) - .with(headers: { 'Accept' => 'application/json' }) + .with(body: attributes) + .with(headers: { 'Accept' => 'application/json' }) end it "returns the record" do @@ -103,7 +103,7 @@ result = response.data expect(result).to be_a(Dnsimple::Struct::Record) - expect(result.id).to be_a(Fixnum) + expect(result.id).to eq(64784) end # context "when the zone does not exist" do @@ -176,4 +176,55 @@ # end end + describe "#update_record" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + before do + stub_request(:patch, %r[/v2/#{account_id}/zones/#{zone_id}/records/.+$]) + .to_return(read_fixture("zones/update_record/success.http")) + end + + let(:attributes) { { content: "127.0.0.1", priority: "1" } } + + it "builds the correct request" do + subject.update_record(account_id, zone_id, record = "3", attributes) + + expect(WebMock).to have_requested(:patch, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record}") + .with(body: attributes) + .with(headers: { 'Accept' => 'application/json' }) + end + + it "returns the record" do + response = subject.update_record(account_id, zone_id, "3") + expect(response).to be_a(Dnsimple::Response) + + result = response.data + expect(result).to be_a(Dnsimple::Struct::Record) + expect(result.id).to eq(64784) + end + + # context "when the zone does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-zone.http")) + # + # expect { + # subject.domain(account_id, zone_id, "0") + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + + # context "when the record does not exist" do + # it "raises NotFoundError" do + # stub_request(:get, %r[/v2]) + # .to_return(read_fixture("notfound-record.http")) + # + # expect { + # subject.domain(account_id, zone_id, "0") + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + end + end diff --git a/spec/files/zones/update_record/success.http b/spec/files/zones/update_record/success.http new file mode 100644 index 00000000..7cc94377 --- /dev/null +++ b/spec/files/zones/update_record/success.http @@ -0,0 +1,17 @@ +HTTP/1.1 200 OK +Server: nginx +Date: Thu, 07 Jan 2016 17:54:46 GMT +Content-Type: application/json; charset=utf-8 +Transfer-Encoding: chunked +Connection: keep-alive +Status: 200 OK +X-RateLimit-Limit: 4000 +X-RateLimit-Remaining: 3988 +X-RateLimit-Reset: 1452189285 +ETag: W/"e870cbe9707d7c1acd0bdb3e4b756cf9" +Cache-Control: max-age=0, private, must-revalidate +X-Request-Id: f320b46c-a7cd-41fe-a061-f38b7a92391f +X-Runtime: 0.103506 +Strict-Transport-Security: max-age=31536000 + +{"data":{"id":64784,"domain_id":5841,"parent_id":null,"name":"www","content":"127.0.0.1","ttl":600,"priority":null,"type":"A","system_record":false,"created_at":"2016-01-07T17:45:13.653Z","updated_at":"2016-01-07T17:54:46.722Z"}} \ No newline at end of file From 7bc81c510901d6cf980b15524c24cad2acf65837 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 19:08:51 +0100 Subject: [PATCH 09/11] Add deleteZoneRecord() --- lib/dnsimple/client/zones_records.rb | 20 ++++++++ spec/dnsimple/client/zones_records_spec.rb | 51 ++++++++++++++++++++- spec/files/zones/delete_record/success.http | 13 ++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 spec/files/zones/delete_record/success.http diff --git a/lib/dnsimple/client/zones_records.rb b/lib/dnsimple/client/zones_records.rb index e6940160..c00816df 100644 --- a/lib/dnsimple/client/zones_records.rb +++ b/lib/dnsimple/client/zones_records.rb @@ -104,6 +104,26 @@ def update_record(account_id, zone_id, record_id, attributes = {}, options = {}) Dnsimple::Response.new(response, Struct::Record.new(response["data"])) end + # Deletes a zone record from the account. + # + # WARNING: this cannot be undone. + # + # @see https://developer.dnsimple.com/v2/zones/records/#delete + # + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard + # @param [String] zone_id the zone name + # @param [Fixnum] record_id the record ID + # @param [Hash] options + # @return [Dnsimple::Response] + # + # @raise [Dnsimple::NotFoundError] + # @raise [Dnsimple::RequestError] + def delete_record(account_id, zone_id, record_id, options = {}) + response = client.delete(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), options) + + Dnsimple::Response.new(response, nil) + end + end end end diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index eded3adc..b66ded41 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -217,11 +217,58 @@ # context "when the record does not exist" do # it "raises NotFoundError" do - # stub_request(:get, %r[/v2]) + # stub_request(:patch, %r[/v2]) # .to_return(read_fixture("notfound-record.http")) # # expect { - # subject.domain(account_id, zone_id, "0") + # subject.update_record(account_id, zone_id, "0", {}) + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + end + + describe "#delete_record" do + let(:account_id) { 1010 } + let(:zone_id) { "example.com" } + + before do + stub_request(:delete, %r[/v2/#{account_id}/zones/#{zone_id}/records/.+$]) + .to_return(read_fixture("zones/delete_record/success.http")) + end + + it "builds the correct request" do + subject.delete_record(account_id, zone_id, record = "3") + + expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record}") + .with(headers: { 'Accept' => 'application/json' }) + end + + it "returns nothing" do + response = subject.delete_record(account_id, zone_id, 3) + expect(response).to be_a(Dnsimple::Response) + + result = response.data + expect(result).to be_nil + end + + # context "when the zone does not exist" do + # it "raises NotFoundError" do + # stub_request(:delete, %r[/v2]) + # .to_return(read_fixture("notfound-zone.http")) + # + # expect { + # subject.delete_record(account_id, zone_id, "0") + # }.to raise_error(Dnsimple::NotFoundError) + # end + # end + + # context "when the record does not exist" do + # it "raises NotFoundError" do + # stub_request(:delete, %r[/v2]) + # .to_return(read_fixture("notfound-record.http")) + # + # expect { + # subject.delete_record(account_id, zone_id, "0") # }.to raise_error(Dnsimple::NotFoundError) # end # end diff --git a/spec/files/zones/delete_record/success.http b/spec/files/zones/delete_record/success.http new file mode 100644 index 00000000..aa75c860 --- /dev/null +++ b/spec/files/zones/delete_record/success.http @@ -0,0 +1,13 @@ +HTTP/1.1 204 No Content +Server: nginx +Date: Thu, 07 Jan 2016 18:06:28 GMT +Connection: keep-alive +Status: 204 No Content +X-RateLimit-Limit: 4000 +X-RateLimit-Remaining: 3987 +X-RateLimit-Reset: 1452189987 +Cache-Control: no-cache +X-Request-Id: 776cea0f-98ae-4550-9a2e-81f8ab27f82b +X-Runtime: 0.099235 +Strict-Transport-Security: max-age=31536000 + From 47198e71438cd07469fafa88f5fd091618839551 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 19:09:02 +0100 Subject: [PATCH 10/11] Update docs --- lib/dnsimple/client/domains.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dnsimple/client/domains.rb b/lib/dnsimple/client/domains.rb index dd59c440..689b24c2 100644 --- a/lib/dnsimple/client/domains.rb +++ b/lib/dnsimple/client/domains.rb @@ -70,7 +70,7 @@ def create_domain(account_id, attributes = {}, options = {}) # # @see https://developer.dnsimple.com/v2/domains/#get # - # @param [Fixnum] account_id the account ID + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard # @param [#to_s] domain_id The domain id or domain name. # @param [Hash] options # @return [Dnsimple::Response] @@ -89,7 +89,7 @@ def domain(account_id, domain_id, options = {}) # # @see https://developer.dnsimple.com/v2/domains/#delete # - # @param [Fixnum] account_id the account ID + # @param [Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT] account_id the account ID or wildcard # @param [#to_s] domain_id The domain id or domain name. # @param [Hash] options # @return [Dnsimple::Response] From 8e839c677ff577eaef37ba10809a480f75724e65 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Thu, 7 Jan 2016 19:09:10 +0100 Subject: [PATCH 11/11] Update commented specs --- spec/dnsimple/client/zones_records_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/dnsimple/client/zones_records_spec.rb b/spec/dnsimple/client/zones_records_spec.rb index b66ded41..60d33e82 100644 --- a/spec/dnsimple/client/zones_records_spec.rb +++ b/spec/dnsimple/client/zones_records_spec.rb @@ -62,7 +62,7 @@ # .to_return(read_fixture("notfound-zone.http")) # # expect { - # subject.domain(account_id, zone_id) + # subject.records(account_id, zone_id) # }.to raise_error(Dnsimple::NotFoundError) # end # end @@ -108,11 +108,11 @@ # context "when the zone does not exist" do # it "raises NotFoundError" do - # stub_request(:get, %r[/v2]) + # stub_request(:post, %r[/v2]) # .to_return(read_fixture("notfound-zone.http")) # # expect { - # subject.domain(account_id, zone_id) + # subject.create_zone(account_id, zone_id, attributes) # }.to raise_error(Dnsimple::NotFoundError) # end # end @@ -159,7 +159,7 @@ # .to_return(read_fixture("notfound-zone.http")) # # expect { - # subject.domain(account_id, zone_id, "0") + # subject.record(account_id, zone_id, "0") # }.to raise_error(Dnsimple::NotFoundError) # end # end @@ -170,7 +170,7 @@ # .to_return(read_fixture("notfound-record.http")) # # expect { - # subject.domain(account_id, zone_id, "0") + # subject.record(account_id, zone_id, "0") # }.to raise_error(Dnsimple::NotFoundError) # end # end @@ -206,11 +206,11 @@ # context "when the zone does not exist" do # it "raises NotFoundError" do - # stub_request(:get, %r[/v2]) + # stub_request(:patch, %r[/v2]) # .to_return(read_fixture("notfound-zone.http")) # # expect { - # subject.domain(account_id, zone_id, "0") + # subject.update_record(account_id, zone_id, "0", {}) # }.to raise_error(Dnsimple::NotFoundError) # end # end