Fix specs for ruby 2.7

Fix specs for ruby 2.7

  • seems the default IPv6 address case has changed in 2.7
  • introduced an eq_i matcher to handle this in some places
  • could not figure out a way to avoid the ?: elsewhere
diff --git a/Gemfile b/Gemfile
index 02faeb3..fdfb987 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
-ruby '> 2.3', '< 2.7'
+ruby '> 2.3', '< 2.8'
 
 source 'https://rubygems.org'
 
diff --git a/Gemfile.lock b/Gemfile.lock
index 7e4e73b..bf2d9e7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -170,4 +170,4 @@ RUBY VERSION
    ruby 2.3.3p222
 
 BUNDLED WITH
-   1.17.3
+   2.1.2
diff --git a/spec/azure_backend_spec.rb b/spec/azure_backend_spec.rb
index 395375f..e97ee4c 100644
--- a/spec/azure_backend_spec.rb
+++ b/spec/azure_backend_spec.rb
@@ -181,7 +181,7 @@ describe DDNSSD::Backend::Azure do
                                            "flingle",
                                            "AAAA",
                                            match_azure_record(
-                                             "properties" => { "TTL" => 42, "AAAARecords" => [{ "ipv6Address" => "2001:DB8::42" }] }))
+                                             "properties" => { "TTL" => 42, "AAAARecords" => [{ "ipv6Address" => RUBY_VERSION >= "2.7" ? "2001:db8::42" : "2001:DB8::42" }] }))
         expect(az_client.record_sets).to_not receive(:list_resource_record_sets)
 
         backend.publish_record(DDNSSD::DNSRecord.new("flingle", 42, :AAAA, "2001:db8::42"))
diff --git a/spec/config_spec.rb b/spec/config_spec.rb
index 8dfe622..bc91048 100644
--- a/spec/config_spec.rb
+++ b/spec/config_spec.rb
@@ -347,7 +347,7 @@ describe DDNSSD::Config do
         expect(dns_record).to be_a(DDNSSD::DNSRecord)
         expect(dns_record.name).to eq(env['DDNSSD_HOSTNAME'])
         expect(dns_record.type).to eq(:AAAA)
-        expect(dns_record.value).to eq('2001:DB8::42')
+        expect(dns_record.value).to eq_i('2001:DB8::42')
       end
     end
   end
diff --git a/spec/dns_record_spec.rb b/spec/dns_record_spec.rb
index 5d02eaf..8c73662 100644
--- a/spec/dns_record_spec.rb
+++ b/spec/dns_record_spec.rb
@@ -243,13 +243,13 @@ describe DDNSSD::DNSRecord do
           end
 
           it "holds the provided address" do
-            expect(record.data.address.to_s).to eq("2001:DB8::42")
+            expect(record.data.address.to_s).to eq_i("2001:DB8::42")
           end
         end
 
         describe "#value" do
           it "returns the address" do
-            expect(record.value).to eq("2001:DB8::42")
+            expect(record.value).to eq_i("2001:DB8::42")
           end
         end
       end
@@ -447,13 +447,13 @@ describe DDNSSD::DNSRecord do
           end
 
           it "holds the provided address" do
-            expect(record.data.address.to_s).to eq("2001:DB8::42")
+            expect(record.data.address.to_s).to eq_i("2001:DB8::42")
           end
         end
 
         describe "#value" do
           it "returns the address" do
-            expect(record.value).to eq("2001:DB8::42")
+            expect(record.value.upcase).to eq("2001:DB8::42")
           end
         end
       end
diff --git a/spec/route53_backend_spec.rb b/spec/route53_backend_spec.rb
index b01ef16..9d8466f 100644
--- a/spec/route53_backend_spec.rb
+++ b/spec/route53_backend_spec.rb
@@ -421,7 +421,7 @@ describe DDNSSD::Backend::Route53 do
                         type: "AAAA",
                         ttl: 42,
                         resource_records: [
-                          { value: "2001:DB8::42" }
+                          { value: RUBY_VERSION >= "2.7" ? "2001:db8::42" : "2001:DB8::42" }
                         ]
                       }
                     }
@@ -1416,7 +1416,7 @@ describe DDNSSD::Backend::Route53 do
                           type: "AAAA",
                           ttl: 42,
                           resource_records: [
-                            { value: "2001:DB8::42" }
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::42" : "2001:DB8::42" }
                           ]
                         }
                       }
@@ -1451,9 +1451,9 @@ describe DDNSSD::Backend::Route53 do
                           type: "AAAA",
                           ttl: 42,
                           resource_records: [
-                            { value: "2001:DB8::1" },
-                            { value: "2001:DB8::42" },
-                            { value: "2001:DB8::180" }
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::1" : "2001:DB8::1" },
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::42" : "2001:DB8::42" },
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::180" : "2001:DB8::180" }
                           ]
                         }
                       },
@@ -1464,8 +1464,8 @@ describe DDNSSD::Backend::Route53 do
                           type: "AAAA",
                           ttl: 42,
                           resource_records: [
-                            { value: "2001:DB8::1" },
-                            { value: "2001:DB8::180" }
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::1" : "2001:DB8::1" },
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::180" : "2001:DB8::180" }
                           ]
                         }
                       }
@@ -1499,8 +1499,8 @@ describe DDNSSD::Backend::Route53 do
                           type: "AAAA",
                           ttl: 42,
                           resource_records: [
-                            { value: "2001:DB8::1" },
-                            { value: "2001:DB8::180" }
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::1" : "2001:DB8::1" },
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::180" : "2001:DB8::180" }
                           ]
                         }
                       },
@@ -1511,8 +1511,8 @@ describe DDNSSD::Backend::Route53 do
                           type: "AAAA",
                           ttl: 42,
                           resource_records: [
-                            { value: "2001:DB8::1" },
-                            { value: "2001:DB8::180" }
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::1" : "2001:DB8::1" },
+                            { value: RUBY_VERSION >= "2.7" ? "2001:db8::180" : "2001:DB8::180" }
                           ]
                         }
                       }
diff --git a/spec/support/matcher_methods.rb b/spec/support/matcher_methods.rb
index 195de62..783e6de 100644
--- a/spec/support/matcher_methods.rb
+++ b/spec/support/matcher_methods.rb
@@ -1,6 +1,16 @@
 # frozen_string_literal: true
 require 'pp'
 
+RSpec::Matchers.define :eq_i do |value|
+  match do |actual|
+    actual.downcase == value.downcase
+  end
+
+  failure_message do |actual|
+    "expected #{actual.pretty_inspect} to equal (case insensitive) '#{value}'"
+  end
+end
+
 RSpec::Matchers.define :have_A_record do |relrrname, address|
   match do |actual|
     actual.any? do |rr|
@@ -20,7 +30,7 @@ RSpec::Matchers.define :have_AAAA_record do |relrrname, address|
     actual.any? do |rr|
       rr.data.class == Resolv::DNS::Resource::IN::AAAA &&
         (relrrname.nil? || rr.name == relrrname) &&
-        (address.nil? || rr.data.address.to_s == address.upcase)
+        (address.nil? || rr.data.address.to_s.downcase == address.downcase)
     end
   end
 

GitHub sha: 819a16e3

This commit appears in #10 which was approved by nlalonde. It was merged by Supermathie.