Skip to content

Commit

Permalink
skip spec that can only run with an internet connection & it can't co…
Browse files Browse the repository at this point in the history
…nnect to its target
  • Loading branch information
robfletcher committed Aug 6, 2013
1 parent c032cd8 commit 8f29857
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@ import static co.freeside.betamax.MatchRule.*
import static co.freeside.betamax.TapeMode.*
import static co.freeside.betamax.util.FileUtils.newTempDir
import static java.net.HttpURLConnection.*
import static java.util.concurrent.TimeUnit.SECONDS

@Unroll
@Stepwise
@IgnoreIf({
def url = "http://httpbin.org/".toURL()
try {
HttpURLConnection connection = url.openConnection()
connection.requestMethod = "HEAD"
connection.connectTimeout = SECONDS.toMillis(2)
connection.connect()
return connection.responseCode >= 400
} catch (IOException e) {
System.err.println "Skipping spec as $url is not available"
return true
}
})
class BasicAuthSpec extends Specification {

@Shared endpoint = 'http://httpbin.org/basic-auth/user/passwd'.toURL()
Expand Down

0 comments on commit 8f29857

Please sign in to comment.