This file contains hidden or 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
route.get("/abc", { req, res -> res.send("Hello") }) | |
route("/abc", { | |
get { req, res -> res.send("Hello") } | |
post { req, res -> req.process(body) } | |
} | |
This file contains hidden or 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 class Given { | |
public fun on(description: String, onExpression: On.() -> Unit) { | |
// code omitted | |
} | |
} | |
This file contains hidden or 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 fun given(description : String, givenExpression: Given.() -> Unit) { | |
// code omitted | |
} | |
public class Given { | |
public fun on(description: String, onExpression: On.() -> Unit) { | |
// code omitted | |
} | |
} |
This file contains hidden or 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
var spaceReplace = { String.(char: Char): String -> this.replace(' ', char) } | |
val output = "This is an example".spaceReplace('_') | |
// outputs: This_is_an_example |
This file contains hidden or 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
it("should do nothing", { | |
given("I have nothing", { | |
on("not doing anything", { | |
}) | |
}) | |
}) |
This file contains hidden or 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
given("I have nothing", { | |
it("should do nothing", { | |
on("not doing anything", { | |
}) | |
}) | |
}) | |
This file contains hidden or 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 fun given(description : String, givenExpression: () -> Unit) { | |
// code omitted | |
} | |
public fun on(description: String, onExpression: () -> Unit) { | |
// code omitted | |
} |
This file contains hidden or 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
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", { |
This file contains hidden or 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
spec public fun calculatorSpecs() { | |
var calculator: Calculator | |
var sum = 0 | |
given("a calculator", { calculator = Calculator() }) | |
This file contains hidden or 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
package samples | |
import kspec.framework.* | |
spec public fun calculatorSpecs() { | |
given("a calculator", { | |
val calculator = Calculator() |