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
object PersonSpec : Spek({ | |
lateinit var person: Person | |
beforeEachGroup { | |
person = Person( | |
name = "name", | |
address = "address", | |
age = 60, | |
isActive = false |
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
lateinit var person: Person | |
beforeEachGroup { | |
person = Person( | |
name = "name", | |
address = "address", | |
age = 60, | |
isActive = false, | |
// Add new argument | |
hasPersonWorked = false |
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
describe("isPersonRetired") { | |
describe("when hasPersonWorked is true") { | |
beforeEachGroup { | |
person.copy(hasPersonWorked = true) | |
} | |
describe("when isActive is true") {...} | |
describe("when isActive is false") {...} |
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
data class Person( | |
val name: String, | |
val address: String, | |
val age: Int, | |
val isActive: Boolean, | |
val hasPersonWorked: Boolean | |
) { | |
fun isPersonRetired() = | |
hasPersonWorked && (!isActive || age > 60) | |
} |
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
private const val RETIREMENT_AGE = 60 | |
data class Person( | |
val name: String, | |
val address: String, | |
val age: Int, | |
val isActive: Boolean | |
) { | |
fun isPersonRetired() = | |
!isActive || age > RETIREMENT_AGE |
OlderNewer