diff --git a/.rubocop.yml b/.rubocop.yml index 0dff9f2..941a5b3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +AllCops: + TargetRubyVersion: 2.4 Style/Documentation: Enabled: false Style/BracesAroundHashParameters: @@ -6,6 +8,12 @@ Style/CommentedKeyword: Enabled: false Style/BlockDelimiters: EnforcedStyle: braces_for_chaining +Layout/LeadingCommentSpace: + Enabled: false +Layout/ClosingParenthesisIndentation: + Enabled: false +Layout/AlignArray: + Enabled: false Metrics/LineLength: Enabled: false Metrics/CyclomaticComplexity: @@ -18,15 +26,3 @@ Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false -Layout/LeadingCommentSpace: - Enabled: false -Layout/FirstParameterIndentation: - Enabled: false -Layout/ClosingParenthesisIndentation: - Enabled: false -Layout/IndentArray: - Enabled: false -Layout/IndentHash: - Enabled: false -Layout/AlignArray: - Enabled: false diff --git a/Gemfile b/Gemfile index 75ac8df..544d3a5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } diff --git a/Rakefile b/Rakefile index 41f9e09..5e98979 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vinyldns.rb b/lib/vinyldns.rb index 6ab2751..cc09f5b 100644 --- a/lib/vinyldns.rb +++ b/lib/vinyldns.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vinyldns/api.rb b/lib/vinyldns/api.rb index 19f7705..941177d 100644 --- a/lib/vinyldns/api.rb +++ b/lib/vinyldns/api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,6 +25,7 @@ def initialize(method, region = 'us-east-1', api_url = ENV['VINYLDNS_API_URL'], @api_url = api_url @method = method.upcase raise(ArgumentError, 'Not a valid http request method') unless %w[GET HEAD POST PUT DELETE TRACE OPTIONS CONNECT PATCH].include?(@method) + @region = region if @method == 'GET' @content_type = content_type @@ -32,11 +35,11 @@ def initialize(method, region = 'us-east-1', api_url = ENV['VINYLDNS_API_URL'], # Generate a signed header for our HTTP requests # http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html @signer = Aws::Sigv4::Signer.new( - service: 'VinylDNS', - region: 'us-east-1', - access_key_id: ENV['VINYLDNS_ACCESS_KEY_ID'], - secret_access_key: ENV['VINYLDNS_SECRET_ACCESS_KEY'], - apply_checksum_header: false # Required for posting body in make_request : http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html : If the 'X-Amz-Content-Sha256' header is set, the :body is optional and will not be read. + service: 'VinylDNS', + region: 'us-east-1', + access_key_id: ENV['VINYLDNS_ACCESS_KEY_ID'], + secret_access_key: ENV['VINYLDNS_SECRET_ACCESS_KEY'], + apply_checksum_header: false # Required for posting body in make_request : http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html : If the 'X-Amz-Content-Sha256' header is set, the :body is optional and will not be read. ) end @@ -45,19 +48,19 @@ def initialize(method, region = 'us-east-1', api_url = ENV['VINYLDNS_API_URL'], # - a uri path. ex: 'zones/92cc1c82-e2fc-424b-a178-f24b18e3b67a' -- This will pull ingest.yourdomain.net's zone def self.make_request(signed_object, uri, body = '') signed_headers = signed_object.signer.sign_request( - http_method: signed_object.method, - url: uri == '/' ? "#{signed_object.api_url}#{uri}" : "#{signed_object.api_url}/#{uri}", - headers: { 'content-type' => signed_object.content_type }, - body: body == '' ? body : body.to_json + http_method: signed_object.method, + url: uri == '/' ? "#{signed_object.api_url}#{uri}" : "#{signed_object.api_url}/#{uri}", + headers: { 'content-type' => signed_object.content_type }, + body: body == '' ? body : body.to_json ) url = URI(signed_object.api_url) https = Net::HTTP.new(url.host, url.port) - https.use_ssl = true ? url.scheme == "https" : https.use_ssl = false - if ENV['VINYLDNS_VERIFY_SSL'] == false || ENV['VINYLDNS_VERIFY_SSL'] =~ /^false$/i - https.verify_mode = OpenSSL::SSL::VERIFY_NONE - else - https.verify_mode = OpenSSL::SSL::VERIFY_PEER - end + https.use_ssl = true ? url.scheme == 'https' : https.use_ssl = false + https.verify_mode = if ENV['VINYLDNS_VERIFY_SSL'] == false || ENV['VINYLDNS_VERIFY_SSL'] =~ /^false$/i + OpenSSL::SSL::VERIFY_NONE + else + OpenSSL::SSL::VERIFY_PEER + end request = Net::HTTP::Post.new(uri == '/' ? uri : "/#{uri}") if signed_object.method == 'POST' request = Net::HTTP::Put.new(uri == '/' ? uri : "/#{uri}") if signed_object.method == 'PUT' request = Net::HTTP::Get.new(uri == '/' ? uri : "/#{uri}") if signed_object.method == 'GET' @@ -65,7 +68,6 @@ def self.make_request(signed_object, uri, body = '') signed_headers.headers.each { |k, v| request[k] = v } request['content-type'] = signed_object.content_type request.body = body == '' ? body : body.to_json - response = https.request(request) case response when Net::HTTPSuccess diff --git a/lib/vinyldns/api/group/group.rb b/lib/vinyldns/api/group/group.rb index 573e7f3..04b7807 100644 --- a/lib/vinyldns/api/group/group.rb +++ b/lib/vinyldns/api/group/group.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,6 +23,7 @@ def self.update(id, request_params) # We use request_params here as require arguments as create arguments may differ from update # Validations raise(ArgumentError, 'Request Parameters must be a Hash') unless request_params.is_a? Hash + api_request_object = Vinyldns::API.new('put') Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}", request_params) end diff --git a/lib/vinyldns/api/zone/zone.rb b/lib/vinyldns/api/zone/zone.rb index 1104c2e..db268e5 100644 --- a/lib/vinyldns/api/zone/zone.rb +++ b/lib/vinyldns/api/zone/zone.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,11 +24,12 @@ def self.connect(name, distribution_email, group_id = nil, group_name_filter = n raise(StandardError, 'Parameter group_object returned nil. This is a problem with the make_request or list_my_groups methods.') if group_object.nil? raise(ArgumentError, 'No group found for your group_name_filter. Please re-check the spelling so it\'s exact.') if group_object.empty? raise(ArgumentError, 'Your group_name_filter used returned more than one group. Please re-check the spelling so it\'s exact.') if group_object.count > 1 + group_id = group_object.first['id'] elsif (group_id.nil? || group_id.empty?) && (group_name_filter.nil? || group_name_filter.empty?) raise(ArgumentError, 'You must include a group_id or group_name_filter.') end # Else, we just use the group_id - parameters = { adminGroupId: group_id, name: name, email: distribution_email} + parameters = { adminGroupId: group_id, name: name, email: distribution_email } parameters.merge!(optional_args) # Post to API api_request_object = Vinyldns::API.new('post') @@ -37,6 +40,7 @@ def self.update(id, request_params) # We use request_params here as values required by create may differ from update # Validations raise(ArgumentError, 'Request Parameters must be a Hash') unless request_params.is_a? Hash + api_request_object = Vinyldns::API.new('put') Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}", request_params) end @@ -78,7 +82,7 @@ class RecordSet @api_uri = 'zones' @api_uri_addition = 'recordsets' - def self.create(zone_id, name, type, ttl, records_array, owner_group_id = "") + def self.create(zone_id, name, type, ttl, records_array, owner_group_id = '') # Post api_request_object = Vinyldns::API.new('post') payload = { 'name': name, 'type': type, 'ttl': ttl, 'records': records_array, 'zoneId': zone_id, 'ownerGroupId': owner_group_id } @@ -90,6 +94,7 @@ def self.update(zone_id, id, request_params) # We use request_params here as values required by create may differ from update # Validations raise(ArgumentError, 'Request Parameters must be a Hash') unless request_params.is_a? Hash + api_request_object = Vinyldns::API.new('put') Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{zone_id}/recordsets/#{id}", request_params) end @@ -120,10 +125,11 @@ class BatchRecordChanges @api_uri = 'zones' @api_uri_addition = 'batchrecordchanges' - def self.create(changes_array, comments="", owner_group_id="") + def self.create(changes_array, comments = '', owner_group_id = '') raise(ArgumentError, 'changes_array parameter must be an Array') unless changes_array.is_a? Array + api_request_object = Vinyldns::API.new('post') - payload = {'changes': changes_array, 'comments': comments, 'ownerGroupId': owner_group_id} + payload = { 'changes': changes_array, 'comments': comments, 'ownerGroupId': owner_group_id } params = Vinyldns::Util.clean_request_payload(payload) Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{@api_uri_addition}", params) end diff --git a/lib/vinyldns/util/util.rb b/lib/vinyldns/util/util.rb index a976303..d5ed556 100644 --- a/lib/vinyldns/util/util.rb +++ b/lib/vinyldns/util/util.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +14,7 @@ module Vinyldns class Util def self.clean_request_payload(payload) - payload.delete_if { |k,v| v.to_s.empty? } + payload.delete_if { |_k, v| v.to_s.empty? } end end end diff --git a/lib/vinyldns/version.rb b/lib/vinyldns/version.rb index 7f9b63c..b8290f0 100644 --- a/lib/vinyldns/version.rb +++ b/lib/vinyldns/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -8,5 +10,5 @@ # See the License for the specific language governing permissions and # limitations under the License. module Vinyldns - VERSION = '0.8.1'.freeze + VERSION = '0.8.1' end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index eecc317..0e1359c 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,6 +46,5 @@ describe 'Make Requests with ENV[\'VINYLDNS_VERIFY_SSL\']' do #TODO end - end end diff --git a/spec/group_spec.rb b/spec/group_spec.rb index 3c71c63..40f0ad8 100644 --- a/spec/group_spec.rb +++ b/spec/group_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,18 +12,18 @@ require 'spec_helper' RSpec.describe Vinyldns::API::Group do before do - Vinyldns::API::Group.create("test-group", "foo@bar.com", [], [], "description") + Vinyldns::API::Group.create('test-group', 'foo@bar.com', [], [], 'description') end after(:all) do - Vinyldns::API::Group.list_my_groups["groups"].each do |group| - Vinyldns::API::Group.delete(group["id"]) + Vinyldns::API::Group.list_my_groups['groups'].each do |group| + Vinyldns::API::Group.delete(group['id']) end end let(:first_group) do - Vinyldns::API::Group.list_my_groups["groups"].find do |group| - group["name"] == "test-group" + Vinyldns::API::Group.list_my_groups['groups'].find do |group| + group['name'] == 'test-group' end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 27f02d4..03fd9e1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +26,7 @@ module Helpers def wait_until_zone_active(zone_id) retries = MAX_RETRIES zone_request = Vinyldns::API::Zone.get(zone_id) - while zone_request.class.name == ("Net::HTTPNotFound") && retries > 0 + while zone_request.class.name == 'Net::HTTPNotFound' && retries.positive? zone_request = Vinyldns::API::Zone.get(zone_id) retries -= 1 sleep(RETRY_WAIT) @@ -35,7 +37,7 @@ def wait_until_zone_active(zone_id) def wait_until_zone_deleted(zone_id) retries = MAX_RETRIES zone_request = Vinyldns::API::Zone.delete(zone_id) - while zone_request.class.name != ("Net::HTTPNotFound") && retries > 0 + while zone_request.class.name != 'Net::HTTPNotFound' && retries.positive? zone_request = Vinyldns::API::Zone.get(zone_id) retries -= 1 sleep(RETRY_WAIT) @@ -46,7 +48,7 @@ def wait_until_zone_deleted(zone_id) def wait_until_recordset_active(zone_id, recordset_id) retries = MAX_RETRIES recordset_request = Vinyldns::API::Zone::RecordSet.get(zone_id, recordset_id) - while recordset_request.class.name == ("Net::HTTPNotFound") && retries > 0 + while recordset_request.class.name == 'Net::HTTPNotFound' && retries.positive? recordset_request = Vinyldns::API::Zone::RecordSet.get(zone_id, recordset_id) retries -= 1 sleep(RETRY_WAIT) @@ -57,15 +59,13 @@ def wait_until_recordset_active(zone_id, recordset_id) def wait_until_batch_change_completed(batch_change) change = batch_change retries = MAX_RETRIES - while !['Complete', 'Failed', 'PartialFailure'].include?(change['status']) && retries > 0 + while !%w[Complete Failed PartialFailure].include?(change['status']) && retries.positive? latest_change = Vinyldns::API::Zone::BatchRecordChanges.get(change['id']) - if(latest_change.class.name != "Net::HTTPNotFound") - change = latest_change - end + change = latest_change if latest_change.class.name != 'Net::HTTPNotFound' retries -= 1 sleep(RETRY_WAIT) end - return change + change end end diff --git a/spec/util_spec.rb b/spec/util_spec.rb index 9737e0c..7ca012a 100644 --- a/spec/util_spec.rb +++ b/spec/util_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -9,10 +11,10 @@ # limitations under the License. require 'spec_helper' describe Vinyldns::Util do - it "removes empty key-value pairs" do - parameters = {one: "", two: 2, three: "three", four: nil} + it 'removes empty key-value pairs' do + parameters = { one: '', two: 2, three: 'three', four: nil } result = Vinyldns::Util.clean_request_payload(parameters) - expect(result).to eq({two: 2, three: "three"}) + expect(result).to eq({ two: 2, three: 'three' }) end end diff --git a/spec/zone_spec.rb b/spec/zone_spec.rb index 1543265..3b27169 100644 --- a/spec/zone_spec.rb +++ b/spec/zone_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -9,19 +11,18 @@ # limitations under the License. require 'spec_helper' describe Vinyldns::API::Zone do - - let(:group) { - Vinyldns::API::Group.create("test-group", "foo@bar.com", [], [], "description") - } + let(:group) do + Vinyldns::API::Group.create('test-group', 'foo@bar.com', [], [], 'description') + end after(:each) do - Vinyldns::API::Zone.search["zones"].each do |zone| - Vinyldns::API::Zone.delete(zone["id"]) - wait_until_zone_deleted(zone["id"]) + Vinyldns::API::Zone.search['zones'].each do |zone| + Vinyldns::API::Zone.delete(zone['id']) + wait_until_zone_deleted(zone['id']) end - Vinyldns::API::Group.list_my_groups["groups"].each do |g| - Vinyldns::API::Group.delete(g["id"]) + Vinyldns::API::Group.list_my_groups['groups'].each do |g| + Vinyldns::API::Group.delete(g['id']) end end @@ -62,28 +63,28 @@ describe '.search' do it 'returns zones' do connection = Vinyldns::API::Zone.connect('ok', group['email'], group['id']) - request = wait_until_zone_active(connection['zone']['id']) - expect(Vinyldns::API::Zone.search["zones"].length).to eq(1) + wait_until_zone_active(connection['zone']['id']) + expect(Vinyldns::API::Zone.search['zones'].length).to eq(1) end end end describe Vinyldns::API::Zone::RecordSet do before(:all) do - group = Vinyldns::API::Group.create("recordset-test-group", "foo@bar.com", [], [], "description") + group = Vinyldns::API::Group.create('recordset-test-group', 'foo@bar.com', [], [], 'description') first_zone_connection = Vinyldns::API::Zone.connect('ok', group['email'], group['id']) wait_until_zone_active(first_zone_connection['zone']['id']) end let(:first_group) do - Vinyldns::API::Group.list_my_groups["groups"].find do |group| - group["name"] == "recordset-test-group" + Vinyldns::API::Group.list_my_groups['groups'].find do |group| + group['name'] == 'recordset-test-group' end end let(:first_zone) do - Vinyldns::API::Zone.search["zones"].find do |zone| - zone["name"] == "ok." + Vinyldns::API::Zone.search['zones'].find do |zone| + zone['name'] == 'ok.' end end @@ -94,55 +95,55 @@ end after(:all) do - Vinyldns::API::Zone.search["zones"].each do |zone| - Vinyldns::API::Zone.delete(zone["id"]) - wait_until_zone_deleted(zone["id"]) + Vinyldns::API::Zone.search['zones'].each do |zone| + Vinyldns::API::Zone.delete(zone['id']) + wait_until_zone_deleted(zone['id']) end - Vinyldns::API::Group.list_my_groups["groups"].each do |g| - Vinyldns::API::Group.delete(g["id"]) + Vinyldns::API::Group.list_my_groups['groups'].each do |g| + Vinyldns::API::Group.delete(g['id']) end end it 'creates a new record' do - request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'testrubyrecordcreate', 'A', 200, [{'address': '1.1.1.1'}]) - expect(request['changeType']).to eq("Create") + request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'testrubyrecordcreate', 'A', 200, [{ 'address': '1.1.1.1' }]) + expect(request['changeType']).to eq('Create') end it 'creates a new record with owner group ID' do - request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'recordcreatewithowner', 'A', 200, [{'address': '1.1.1.1'}], first_group['id']) + request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'recordcreatewithowner', 'A', 200, [{ 'address': '1.1.1.1' }], first_group['id']) wait_until_recordset_active(first_zone['id'], request['recordSet']['id']) expect(request['recordSet']['ownerGroupId']).to eq(first_group['id']) end it 'updates' do - request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'testrubyrecordupdate', 'A', 200, [{'address': '1.1.1.1'}]) - expect(request['changeType']).to eq("Create") + request = Vinyldns::API::Zone::RecordSet.create(first_zone['id'], 'testrubyrecordupdate', 'A', 200, [{ 'address': '1.1.1.1' }]) + expect(request['changeType']).to eq('Create') wait_until_recordset_active(first_zone['id'], request['recordSet']['id']) - request['recordSet']['records'] = [{'address': '1.2.2.2'}] + request['recordSet']['records'] = [{ 'address': '1.2.2.2' }] update_request = Vinyldns::API::Zone::RecordSet.update(request['zone']['id'], request['recordSet']['id'], request['recordSet']) - expect(update_request['changeType']).to eq("Update") + expect(update_request['changeType']).to eq('Update') end end describe Vinyldns::API::Zone::BatchRecordChanges do before(:all) do - group = Vinyldns::API::Group.create("another-test-group", "foo@bar.com", [], [], "description") + group = Vinyldns::API::Group.create('another-test-group', 'foo@bar.com', [], [], 'description') zone_connection = Vinyldns::API::Zone.connect('ok', group['email'], group['id']) wait_until_zone_active(zone_connection['zone']['id']) end let(:first_zone) do - Vinyldns::API::Zone.search["zones"].find do |zone| - zone["name"] == "ok." + Vinyldns::API::Zone.search['zones'].find do |zone| + zone['name'] == 'ok.' end end let(:first_group) do - Vinyldns::API::Group.list_my_groups["groups"].find do |group| - group["name"] == "another-test-group" + Vinyldns::API::Group.list_my_groups['groups'].find do |group| + group['name'] == 'another-test-group' end end @@ -153,12 +154,12 @@ end after(:all) do - Vinyldns::API::Group.list_my_groups["groups"].each do |group| - Vinyldns::API::Group.delete(group["id"]) + Vinyldns::API::Group.list_my_groups['groups'].each do |group| + Vinyldns::API::Group.delete(group['id']) end - Vinyldns::API::Zone.search["zones"].each do |zone| - Vinyldns::API::Zone.delete(zone["id"]) - wait_until_zone_deleted(zone["id"]) + Vinyldns::API::Zone.search['zones'].each do |zone| + Vinyldns::API::Zone.delete(zone['id']) + wait_until_zone_deleted(zone['id']) end end @@ -169,39 +170,39 @@ end it 'raises error if zones don\'t exist to delete' do request = Vinyldns::API::Zone::BatchRecordChanges.create( - [ - { - 'inputName': 'testvinyldnsruby.dodo.', - 'changeType': 'DeleteRecordSet', - 'type': 'A' - } - ], 'vinyldns-ruby gem testing' + [ + { + 'inputName': 'testvinyldnsruby.dodo.', + 'changeType': 'DeleteRecordSet', + 'type': 'A' + } + ], 'vinyldns-ruby gem testing' ) - expect(request.class.name).to eq("Net::HTTPBadRequest") - expect(request.body).to include("does not exist in VinylDNS") + expect(request.class.name).to eq('Net::HTTPBadRequest') + expect(request.body).to include('does not exist in VinylDNS') end it 'can POST' do request = Vinyldns::API::Zone::BatchRecordChanges.create( - [ - { - 'inputName': 'testvinyldnsruby.ok.', - 'changeType': 'Add', - 'type': 'A', - "ttl": 3600, - "record": { - "address": '1.1.1.2' - } - }, - { - 'inputName': 'testvinyldnsruby2.ok.', - 'changeType': 'Add', - 'type': 'A', - "ttl": 3600, - "record": { - "address": '11.11.11.11' - } + [ + { + 'inputName': 'testvinyldnsruby.ok.', + 'changeType': 'Add', + 'type': 'A', + "ttl": 3600, + "record": { + "address": '1.1.1.2' + } + }, + { + 'inputName': 'testvinyldnsruby2.ok.', + 'changeType': 'Add', + 'type': 'A', + "ttl": 3600, + "record": { + "address": '11.11.11.11' } - ], 'vinyldns-ruby gem testing' + } + ], 'vinyldns-ruby gem testing' ) completed_batch = wait_until_batch_change_completed(request) expect(completed_batch['changes'].length).to eq(2) @@ -211,44 +212,44 @@ it 'can DELETE' do request = Vinyldns::API::Zone::BatchRecordChanges.create( [ - { - 'inputName': 'testvinyldnsruby2.ok.', - 'changeType': 'DeleteRecordSet', - 'type': 'A' - } + { + 'inputName': 'testvinyldnsruby2.ok.', + 'changeType': 'DeleteRecordSet', + 'type': 'A' + } ], 'vinyldns-ruby gem testing' ) completed_batch = wait_until_batch_change_completed(request) expect(completed_batch['changes'].length).to eq(1) - expect(completed_batch['changes'][0].has_value?("testvinyldnsruby2.ok.")) - expect(completed_batch['changes'][0].has_value?("DeleteRecordSet")) - expect(completed_batch['changes'][0].has_value?("A")) + expect(completed_batch['changes'][0].value?('testvinyldnsruby2.ok.')) + expect(completed_batch['changes'][0].value?('DeleteRecordSet')) + expect(completed_batch['changes'][0].value?('A')) expect(completed_batch['comments']).to eq('vinyldns-ruby gem testing') expect(completed_batch['status']).to eq('Complete') end it 'can POST with ownerGroupId' do request = Vinyldns::API::Zone::BatchRecordChanges.create( - [ - { - 'inputName': 'testvinyldnsruby3.ok.', - 'changeType': 'Add', - 'type': 'A', - "ttl": 3600, - "record": { - "address": '1.1.1.2' - } - }, - { - 'inputName': 'testvinyldnsruby4.ok.', - 'changeType': 'Add', - 'type': 'A', - "ttl": 3600, - "record": { - "address": '11.11.11.11' - } + [ + { + 'inputName': 'testvinyldnsruby3.ok.', + 'changeType': 'Add', + 'type': 'A', + "ttl": 3600, + "record": { + "address": '1.1.1.2' + } + }, + { + 'inputName': 'testvinyldnsruby4.ok.', + 'changeType': 'Add', + 'type': 'A', + "ttl": 3600, + "record": { + "address": '11.11.11.11' } - ], 'vinyldns-ruby gem testing', - first_group['id'] + } + ], 'vinyldns-ruby gem testing', + first_group['id'] ) completed_batch = wait_until_batch_change_completed(request) expect(completed_batch['changes'].length).to eq(2) diff --git a/vinyldns.gemspec b/vinyldns.gemspec index 6a5a710..cbb9a24 100644 --- a/vinyldns.gemspec +++ b/vinyldns.gemspec @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Copyright 2018 Comcast Cable Communications Management, LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,10 +38,11 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.add_runtime_dependency 'aws-sigv4', '~> 1.0' gem.add_development_dependency 'bundler', '~> 1.13' + gem.add_development_dependency 'pry', '~> 0.10.3' gem.add_development_dependency 'rake', '~> 12.0' - gem.add_development_dependency 'rspec', '3.7.0' gem.add_development_dependency 'rb-readline', '~> 0.5.5' - gem.add_development_dependency 'pry', '~> 0.10.3' + gem.add_development_dependency 'rspec', '3.7.0' + gem.add_development_dependency 'rubocop', '~> 0.68.1' # Dependencies # Licensed uses the the libgit2 bindings for Ruby provided by rugged. rugged has its own dependencies - cmake and pkg-config - which you may need to install before you can install Licensed. # For example, on macOS with Homebrew: brew install cmake pkg-config and on Ubuntu: apt-get install cmake pkg-config.