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
Spock For Non-Believers | |
Which code would you rather want to read, write, and maintain? Choose the right answer and win a trip to Vulcan! | |
A. B. | |
/* Seven lines of imports removed for clarity */ /* Zero lines of imports removed for clarity */ | |
@RunWith(Parameterized.class) class HelloSpock extends spock.lang.Specification { | |
public class HelloSpock { def "length of Spock and friends"() { |
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
<html> | |
<head> | |
</head> | |
<body> | |
<div class="spec"> | |
<div class="details"> | |
<div class="name">My first spec</div> | |
<div class="duration">3 mins 17 seconds</div> | |
<div class="result">fail</div> | |
</div> |
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
<html> | |
<head> | |
</head> | |
<body> | |
<div class="spec pass/some-fail/fail first/last odd/even" id="«spec-class-name»"> | |
<div class="details"> | |
<div class="name">My first spec</div> | |
<div class="duration">3 mins 17 seconds</div> | |
<div class="result">fail</div> | |
</div> |
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
void next() { | |
nextButton.click() | |
waitForAnimationComplete() | |
} | |
private void waitForAnimationComplete() { | |
waitFor { this.jquery."find(':animated').length == 0" } | |
} |
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
import org.jsoup.Jsoup | |
import org.jsoup.nodes.Document | |
class JSoupFilterReader extends FilterReader { | |
Closure withDocument | |
JSoupFilterReader(Reader reader) { | |
super(new DeferringReader(reader)); | |
this.in.parent = this |
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
sourceSets { | |
functionalTest { | |
task functionalTest(type: Test) { | |
testClassesDir = output.classesDir | |
testSrcDirs = java.srcDirs.toList() | |
classpath = runtimeClasspath | |
} | |
} | |
} |
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
Handler<T> handler(@DelegatesTo.Target(asType = true) Class<T> type, @DelegatesTo Closure<?> configurer) { | |
return new Handler() { | |
void handle(T object) { | |
configurer.delegate = object | |
configure.call(delegate) | |
} | |
} | |
} |
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
allprojects { | |
tasks.withType(Upload) { | |
allprojects { | |
mustRunAfter tasks.matching { it instanceof VerificationTask } | |
} | |
} | |
} |
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
def "can handle errors on forked threads"() { | |
given: | |
def errorHandler = new ErrorHandlingContext() { | |
void error(Exchange exchange, Exception exception) { | |
exchange.response.send("Caught: $exception.message") | |
} | |
} | |
when: | |
app { |
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
public String getBindHost() { | |
if (boundAddress == null) { | |
return null; | |
} else { | |
InetAddress address = boundAddress.getAddress(); | |
if (address.isAnyLocalAddress()) { | |
return "localhost"; | |
} else { | |
return address.getHostAddress(); | |
} |
OlderNewer