Add flag for specs that should be skipped if currently not connected to the internet

This commit is contained in:
nritholtz 2015-03-20 16:07:34 -04:00 committed by Matthew Horan
parent 73971d9b7f
commit 079e6cbca1
2 changed files with 14 additions and 2 deletions

View File

@ -2568,7 +2568,7 @@ CACHE MANIFEST
end
end
describe "url blacklisting" do
describe "url blacklisting", skip_if_offline: true do
let(:driver) do
driver_for_app do
get "/" do
@ -2651,7 +2651,7 @@ CACHE MANIFEST
end
end
describe "url whitelisting" do
describe "url whitelisting", skip_if_offline: true do
it_behaves_like "output writer" do
let(:driver) do
driver_for_html(<<-HTML, browser)

View File

@ -23,12 +23,24 @@ Capybara.register_driver :reusable_webkit do |app|
Capybara::Webkit::Driver.new(app, :browser => $webkit_browser)
end
def has_internet?
require 'resolv'
dns_resolver = Resolv::DNS.new
begin
dns_resolver.getaddress("example.com")
true
rescue Resolv::ResolvError => e
false
end
end
RSpec.configure do |c|
Capybara::SpecHelper.configure(c)
c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
c.filter_run_excluding :skip_on_jruby => !defined?(::JRUBY_VERSION).nil?
c.filter_run_excluding :selenium_compatibility => (Capybara::VERSION =~ /^2\.4\./).nil?
c.filter_run_excluding :skip_if_offline => !has_internet?
# We can't support outerWidth and outerHeight without a visible window.
# We focus the next window instead of failing when closing windows.