Skip to content

Instantly share code, notes, and snippets.

@tomohiro-n
Created November 9, 2017 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomohiro-n/c2a86ba8f1286513387ec35a4199e8a7 to your computer and use it in GitHub Desktop.
Save tomohiro-n/c2a86ba8f1286513387ec35a4199e8a7 to your computer and use it in GitHub Desktop.
Kotlin meetup - Spek sample
package tomohiron.kotlinserver.service
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import java.time.OffsetDateTime
object DateTimeServiceSpec: Spek({
describe("DateTimeService") {
val dateTimeService = DateTimeService()
on("isDateTimeFresh") {
it("should be able to judge if the specified time is less than 10 second old") {
val oldTime = OffsetDateTime.now().minusSeconds(11)
assertFalse(dateTimeService.isDateTimeFresh(oldTime))
val freshTime = OffsetDateTime.now().minusSeconds(9)
assertTrue(dateTimeService.isDateTimeFresh(freshTime))
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment