Skip to content

Commit

Permalink
Tidy up tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 16, 2024
1 parent 4f2879a commit 9cb0ee6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/async/dns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def records_for(name, resource_classes)
end
end

if System.use_ipv6?
if System.ipv6?
ADDRESS_RESOURCE_CLASSES = [Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::AAAA]
else
ADDRESS_RESOURCE_CLASSES = [Resolv::DNS::Resource::IN::A]
Expand Down
2 changes: 1 addition & 1 deletion lib/async/dns/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.hosts_path
end
end

def self.use_ipv6?
def self.ipv6?
begin
list = Socket.ip_address_list
rescue NotImplementedError
Expand Down
5 changes: 4 additions & 1 deletion test/async/dns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
addresses = resolver.addresses_for('google.com')

expect(addresses).to have_value(be_a Resolv::IPv4)
expect(addresses).to have_value(be_a Resolv::IPv6)

if Async::DNS::System.ipv6?
expect(addresses).to have_value(be_a Resolv::IPv6)
end
end

it "should recursively resolve CNAME records" do
Expand Down
11 changes: 0 additions & 11 deletions test/async/dns/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ def make_server(endpoint)
answer: be(:empty?)
)
end

it "should return IPv4 and IPv6 addresses" do
response = resolver.query("www.google.com", Resolv::DNS::Resource::IN::A)

expect(response).to have_attributes(
qr: be == 1,
rcode: be == Resolv::DNS::RCode::NoError,
question: have_attributes(size: be == 1),
answer: have_attributes(size: be > 0)
)
end
end

with 'a large response' do
Expand Down

0 comments on commit 9cb0ee6

Please sign in to comment.