Created
November 9, 2017 05:23
-
-
Save tomohiro-n/c2a86ba8f1286513387ec35a4199e8a7 to your computer and use it in GitHub Desktop.
Kotlin meetup - Spek sample
This file contains 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 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