Skip to content

Commit

Permalink
Fix system hosts tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 2, 2024
1 parent 683e59e commit e8ee16b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 3 additions & 6 deletions lib/async/dns/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ def initialize
@names = {}
end

# This is used to match names against the list of known hosts:
def call(name)
@names.include?(name)
end

# Lookup a name in the hosts file.
def lookup(name)
def lookup(name, origin: nil)
name = Resolv::DNS::Name.create(name).with_origin(origin)

addresses = @names[name]

if addresses
Expand Down
7 changes: 3 additions & 4 deletions test/async/dns/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

it "should parse the hosts file" do
hosts = Async::DNS::System::Hosts.new

# Load the test hosts data:
File.open(hosts_path) do |file|
hosts.parse_hosts(file)
end

expect(hosts.call('testing')).to be == true
expect(hosts['testing']).to be == '1.2.3.4'

expect(hosts['testing']).to be == Resolv::IPv4.create("1.2.3.4")
end
end

0 comments on commit e8ee16b

Please sign in to comment.