Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
it("should do nothing", {
given("I have nothing", {
on("not doing anything", {
})
})
})
var spaceReplace = { String.(char: Char): String -> this.replace(' ', char) }
val output = "This is an example".spaceReplace('_')
// outputs: This_is_an_example
public fun given(description : String, givenExpression: Given.() -> Unit) {
// code omitted
}
public class Given {
public fun on(description: String, onExpression: On.() -> Unit) {
// code omitted
}
}
public class Given {
public fun on(description: String, onExpression: On.() -> Unit) {
// code omitted
}
}
route.get("/abc", { req, res -> res.send("Hello") })
route("/abc", {
get { req, res -> res.send("Hello") }
post { req, res -> req.process(body) }
}
resource "/customer" get { response.send("a....") }
resource public fun CustomerResources() {
"/customer" get {
}
"/customer" post {
val server = AppServer()
Routes.get("/good",{ response.send("Well this means that routes now work!")})
Routes.get("/",{ response.send("Hello, how are you")})
"/customer" post { response.send("abc") }
<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><statusCode>200</statusCode><statusText>Test Complete</statusText><data><statusCode>200</statusCode><statusText>Test Complete</statusText><testId>130511_3N_P78</testId><runs>1</runs><fvonly>0</fvonly><remote></remote><testsExpected>2</testsExpected><location>Dulles_IE9</location><startTime>05/11/13 18:57:43</startTime><elapsed>178752</elapsed><completeTime>05/11/13 18:57:51</completeTime><testsCompleted>2</testsCompleted></data></response>
Routes.get("/customer/10", {
val obj = object {
val name = "John"
}
response.send(obj, ContentType.ApplicationJson)
})