From 3a21b7c29c50fd415b76da141204597a11c2b5e2 Mon Sep 17 00:00:00 2001 From: "M. Scott Ford" Date: Tue, 26 Jul 2011 16:51:22 -0400 Subject: [PATCH] Added test to make sure that test.example.com can be resolved through /etc/hosts. --- features/support/env.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/features/support/env.rb b/features/support/env.rb index 45e0db4f..efcb084c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -19,10 +19,25 @@ require 'capybara/rails' require 'capybara/cucumber' require 'capybara/session' +require 'resolv' +require 'uri' + +def ensure_host_resolution(app_host) + hosts = Resolv::Hosts.new + app_host_name = URI.parse(app_host).host + begin + hosts.getaddress(app_host_name) + rescue Resolv::ResolvError + raise "Unable to resolve ip address for #{app_host_name}. Please consider adding an entry to '/etc/hosts' that associates #{app_host_name} with '127.0.0.1'." + end +end + Capybara.configure do |config| config.default_selector = :css config.server_port = 9886 config.app_host = 'http://test.example.com:9886' + + ensure_host_resolution(config.app_host) end # Capybara.javascript_driver = :rack_test