We are using the rest-client gem in Ruby for automated testing of our REST API. However I noticed that on every single request it makes, it also does a DNS lookup for the host name. On the local environment if "localhost" is used the tests run fast, but if the proper hostname is used they take 2.5x the time, performing a huge number of DNS lookups.
I believe this issue is not related to rest-client in particular, but the base Ruby networking. I tried requiring 'resolv' and 'resolv-replace' but they did not help. 'dig' reports that the DNS query has a TTL of 1 hour.
Is there a way to make Ruby cache DNS requests? I could change the code to explicitly use the IP address, but that's the wrong place to fix the issue.
I'm running Ubuntu 12.04 and Ruby 1.9.3.