Created
May 17, 2011 10:48
-
-
Save matthewrudy/976285 to your computer and use it in GitHub Desktop.
A quick hack to check there is internet before running some testcases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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