Fix Resolv specs to not depend on a system /etc/hosts file

* https://rubyci.org/logs/rubyci.s3.amazonaws.com/archlinux/ruby-master/log/20190609T153804Z.fail.html.gz
* Thanks @naruse for the tip.
This commit is contained in:
Benoit Daloze 2019-06-10 12:45:00 +02:00
Родитель 614154bbb6
Коммит 60af6fef3c
5 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -0,0 +1 @@
127.0.0.1 localhost localhost4

Просмотреть файл

@ -4,11 +4,11 @@ require 'resolv'
describe "Resolv#getaddress" do
platform_is_not :windows do
it "resolves localhost" do
res = Resolv.new([Resolv::Hosts.new])
hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
res = Resolv.new([hosts])
lambda {
res.getaddress("localhost")
}.should_not raise_error(Resolv::ResolvError)
res.getaddress("localhost").should == "127.0.0.1"
res.getaddress("localhost4").should == "127.0.0.1"
end
end

Просмотреть файл

@ -4,11 +4,11 @@ require 'resolv'
describe "Resolv#getaddresses" do
platform_is_not :windows do
it "resolves localhost" do
res = Resolv.new([Resolv::Hosts.new])
hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
res = Resolv.new([hosts])
addresses = res.getaddresses("localhost")
addresses.should_not == nil
addresses.size.should > 0
res.getaddresses("localhost").should == ["127.0.0.1"]
res.getaddresses("localhost4").should == ["127.0.0.1"]
end
end
end

Просмотреть файл

@ -4,9 +4,10 @@ require 'resolv'
describe "Resolv#getname" do
platform_is_not :windows do
it "resolves 127.0.0.1" do
lambda {
Resolv.getname("127.0.0.1")
}.should_not raise_error(Resolv::ResolvError)
hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
res = Resolv.new([hosts])
res.getname("127.0.0.1").should == "localhost"
end
end

Просмотреть файл

@ -4,11 +4,10 @@ require 'resolv'
describe "Resolv#getnames" do
platform_is_not :windows do
it "resolves 127.0.0.1" do
res = Resolv.new([Resolv::Hosts.new])
hosts = Resolv::Hosts.new(fixture(__FILE__ , "hosts"))
res = Resolv.new([hosts])
names = res.getnames("127.0.0.1")
names.should_not == nil
names.size.should > 0
names = res.getnames("127.0.0.1").should == ["localhost", "localhost4"]
end
end
end