ruby-changes:56063
From: Benoit <ko1@a...>
Date: Mon, 10 Jun 2019 19:48:08 +0900 (JST)
Subject: [ruby-changes:56063] Benoit Daloze: 60af6fef3c (trunk): Fix Resolv specs to not depend on a system /etc/hosts file
https://git.ruby-lang.org/ruby.git/commit/?id=60af6fef3c From 60af6fef3c664ac7dab53fcde28c30f30ce862aa Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Mon, 10 Jun 2019 12:45:00 +0200 Subject: 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. diff --git a/spec/ruby/library/resolv/fixtures/hosts b/spec/ruby/library/resolv/fixtures/hosts new file mode 100644 index 0000000..a50f3d6 --- /dev/null +++ b/spec/ruby/library/resolv/fixtures/hosts @@ -0,0 +1 @@ +127.0.0.1 localhost localhost4 diff --git a/spec/ruby/library/resolv/get_address_spec.rb b/spec/ruby/library/resolv/get_address_spec.rb index 3506a65..eecf5e0 100644 --- a/spec/ruby/library/resolv/get_address_spec.rb +++ b/spec/ruby/library/resolv/get_address_spec.rb @@ -4,11 +4,11 @@ require 'resolv' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/resolv/get_address_spec.rb#L4 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 diff --git a/spec/ruby/library/resolv/get_addresses_spec.rb b/spec/ruby/library/resolv/get_addresses_spec.rb index c484161..7e89c3c 100644 --- a/spec/ruby/library/resolv/get_addresses_spec.rb +++ b/spec/ruby/library/resolv/get_addresses_spec.rb @@ -4,11 +4,11 @@ require 'resolv' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/resolv/get_addresses_spec.rb#L4 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 diff --git a/spec/ruby/library/resolv/get_name_spec.rb b/spec/ruby/library/resolv/get_name_spec.rb index 0433836..006014b 100644 --- a/spec/ruby/library/resolv/get_name_spec.rb +++ b/spec/ruby/library/resolv/get_name_spec.rb @@ -4,9 +4,10 @@ require 'resolv' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/resolv/get_name_spec.rb#L4 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 diff --git a/spec/ruby/library/resolv/get_names_spec.rb b/spec/ruby/library/resolv/get_names_spec.rb index fa77ba7..897e24e 100644 --- a/spec/ruby/library/resolv/get_names_spec.rb +++ b/spec/ruby/library/resolv/get_names_spec.rb @@ -4,11 +4,10 @@ require 'resolv' https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/resolv/get_names_spec.rb#L4 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/