Skip to content

Instantly share code, notes, and snippets.

@matthewrudy
Created May 17, 2011 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewrudy/976285 to your computer and use it in GitHub Desktop.
Save matthewrudy/976285 to your computer and use it in GitHub Desktop.
A quick hack to check there is internet before running some testcases
module IsThereInternet
def is_there_internet?
if $IS_THERE_INTERNET.nil?
$IS_THERE_INTERNET = system "ping -q -c 1 google.com 1> /dev/null"
end
$IS_THERE_INTERNET
end
# test "something" do
# requires_internet! do
# # my test case here
# end
# end
#
def requires_internet!
if is_there_internet?
yield
else
flunk "this test needs to be run when there is internet"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment