Skip to content

Instantly share code, notes, and snippets.

Rob Fletcher robfletcher

Block or report user

Report or block robfletcher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View NullOrUnitWasNotCalled.kt
import io.mockk.Called
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import org.junit.jupiter.api.Test
import java.util.function.Consumer
import java.util.function.Supplier
class NullOrUnitWasNotCalled {
robfletcher / MockkUnitLambdaTest.kt
Created Mar 16, 2019
Demonstration of error verifying calls to a lambda that returns `Unit`
View MockkUnitLambdaTest.kt
import io.mockk.mockk
import io.mockk.verify
import org.junit.jupiter.api.Test
class MockkUnitLambdaTest {
fun mockUnitLambda() {
val fn: (String) -> Unit = mockk(relaxUnitFun = true)
robfletcher / SetPropertySpec.groovy
Last active Feb 25, 2019
Demonstrates issue with comparing objects with set properties whose elements are > 1 level deep value objects
View SetPropertySpec.groovy
import groovy.transform.TupleConstructor
import org.javers.core.JaversBuilder
import org.javers.core.diff.changetype.container.SetChange
import org.javers.core.diff.changetype.container.ValueAdded
import org.javers.core.metamodel.annotation.Id
import spock.lang.Specification
import static java.util.UUID.randomUUID
class SetPropertySpec extends Specification {
robfletcher / ThinkSpec.kt
Created Jun 7, 2017
Example of trying to use `SubjectSpek` and `itBehavesLike` if the subject requires a collaborator
View ThinkSpec.kt
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.on
import org.jetbrains.spek.subject.SubjectSpek
import org.jetbrains.spek.subject.itBehavesLike
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
open class Thing(protected val fn: () -> Unit) {
View TableSpec.kt
import org.jetbrains.spek.api.Spek
class TableSpec : Spek({
describe("using a table") {
table { a: String, b: Int ->
describe("$a and $b are parameters") {
it("should work") {
assert(a is String)
assert(b is Int)
View MapWtf.groovy
import groovy.transform.*
Map<String, ?> makeMap() {
def map = [string: "string"]
map.number = 1
return map
def map = makeMap()
robfletcher / InteropNullabilitySpec.kt
Last active Feb 24, 2016
Example of how Kotlin treats nullability of Java types
View InteropNullabilitySpec.kt
import org.jetbrains.spek.api.*
class InteropNullabilitySpec : Spek() {
init {
given("a java object with null state") {
val obj = JavaStringWrapper(null)
on("calling a getter that will return null") {
it("allows me to assign the result to a nullable type") {
val s: String? = obj.value
robfletcher / Diamond.kt
Last active Feb 18, 2016
The diamond kata in Kotlin
View Diamond.kt
fun diamond(c: Char): String {
if (c !in 'A'..'Z') throw IllegalArgumentException()
return ('A'..c)
private fun row(max: Char) = { next: Char ->
View byMethod.groovy
.byMethod(spec ->
.get(() -> ctx.render("GET"))
.post(() -> ctx.render("POST"))
View Spirit.scala
import com.fasterxml.jackson.annotation.JsonSubTypes.Type
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}
@JsonTypeInfo(use = Id.NAME, property = "name")
new Type(classOf[Vodka.type]),
new Type(classOf[Whiskey])
trait Spirit
You can’t perform that action at this time.