From b65f17a630c908c28d561c3d785ea8f0c46a74e3 Mon Sep 17 00:00:00 2001 From: Robin Wallin Date: Mon, 21 Aug 2023 09:17:01 +0200 Subject: [PATCH] `rubocop -a` --- test/sparoid_test.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/sparoid_test.rb b/test/sparoid_test.rb index 99a06fb..72f282b 100644 --- a/test/sparoid_test.rb +++ b/test/sparoid_test.rb @@ -8,7 +8,7 @@ def test_that_it_has_a_version_number end def test_it_resolves_public_ip - assert Sparoid.send(:public_ip).to_s =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ + assert_match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, Sparoid.send(:public_ip).to_s) end def test_it_creates_a_message @@ -17,6 +17,7 @@ def test_it_creates_a_message def test_it_encrypts_messages key = "0000000000000000000000000000000000000000000000000000000000000000" + assert_equal 64, Sparoid.send(:encrypt, key, Sparoid.send(:message, Sparoid.send(:public_ip))).bytesize end @@ -24,6 +25,7 @@ def test_it_adds_hmac key = "0000000000000000000000000000000000000000000000000000000000000000" msg = Sparoid.send(:encrypt, key, Sparoid.send(:message, Sparoid.send(:public_ip))) hmac_key = "0000000000000000000000000000000000000000000000000000000000000000" + assert_equal 96, Sparoid.send(:prefix_hmac, hmac_key, msg).bytesize end @@ -35,6 +37,7 @@ def test_it_sends_message port = server.addr[1] Sparoid.auth(key, hmac_key, "127.0.0.1", port) msg, = server.recvfrom(512) + assert_equal 96, msg.bytesize end end @@ -74,6 +77,7 @@ def test_it_raises_resolve_error_on_dns_socket_error key = "0000000000000000000000000000000000000000000000000000000000000000" hmac_key = "0000000000000000000000000000000000000000000000000000000000000000" error = ->(*_) { raise SocketError, "getaddrinfo: Name or service not known" } + Addrinfo.stub(:getaddrinfo, error) do assert_raises(Sparoid::ResolvError) do Sparoid::Instance.new.auth(key, hmac_key, "127.0.0.1", 1337) @@ -90,6 +94,7 @@ def test_instance_sends_message port = server.addr[1] s.auth(key, hmac_key, "127.0.0.1", port) msg, = server.recvfrom(512) + assert_equal 96, msg.bytesize end end