Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
route.get("/abc", { req, res -> res.send("Hello") })
route("/abc", {
get { req, res -> res.send("Hello") }
post { req, res -> req.process(body) }
}
public class Given {
public fun on(description: String, onExpression: On.() -> Unit) {
// code omitted
}
}
public fun given(description : String, givenExpression: Given.() -> Unit) {
// code omitted
}
public class Given {
public fun on(description: String, onExpression: On.() -> Unit) {
// code omitted
}
}
var spaceReplace = { String.(char: Char): String -> this.replace(' ', char) }
val output = "This is an example".spaceReplace('_')
// outputs: This_is_an_example
it("should do nothing", {
given("I have nothing", {
on("not doing anything", {
})
})
})
given("I have nothing", {
it("should do nothing", {
on("not doing anything", {
})
})
})
public fun given(description : String, givenExpression: () -> Unit) {
// code omitted
}
public fun on(description: String, onExpression: () -> Unit) {
// code omitted
}
@hhariri
hhariri / SpekSample.kt
Created January 21, 2013 14:47
Spek Example
given("a calculator", {
val calculator = Calculator()
on("calling sum with two numbers", {
val sum = calculator.sum(2, 3)
it("should return the sum of the two numbers", {
spec public fun calculatorSpecs() {
var calculator: Calculator
var sum = 0
given("a calculator", { calculator = Calculator() })
package samples
import kspec.framework.*
spec public fun calculatorSpecs() {
given("a calculator", {
val calculator = Calculator()