Skip to content

Instantly share code, notes, and snippets.

@IvanShafran
Last active August 22, 2019 10:45
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 IvanShafran/13777b0f7850bd94420bb901fd17ff13 to your computer and use it in GitHub Desktop.
Save IvanShafran/13777b0f7850bd94420bb901fd17ff13 to your computer and use it in GitHub Desktop.
class ShowRateUsLogicTest : Spek({
// property declaration, setup and preparation are skipped
describe("show rate us logic") {
context("first conditions checks") {
context("buy clicked once") {
beforeEachTest {
prepareConditions(buyClickedTimes = 1)
}
it("should not show 'rate us'") {
Assert.assertFalse(showRateUsLogic.shouldShowRateUs())
}
}
context("buy clicked two times") {
beforeEachTest {
prepareConditions(buyClickedTimes = 2)
}
it("should show 'rate us'") {
Assert.assertTrue(showRateUsLogic.shouldShowRateUs())
}
}
}
context("'rate us' was shown already, and user clicked 'show me later' on the dialog") {
context("less than two months passed and user clicks buy") {
beforeEachTest {
prepareConditions(
buyClickedTimes = 3,
lastShownTimeMillis = SOME_DAY_IN_MILLIS,
currentTimeMillis = SOME_DAY_IN_MILLIS + LESS_THAN_TWO_MONTHS
)
}
it("should not show 'rate us' again") {
Assert.assertFalse(showRateUsLogic.shouldShowRateUs())
}
}
context("more than two months passed and user clicks buy") {
beforeEachTest {
prepareConditions(
buyClickedTimes = 3,
lastShownTimeMillis = SOME_DAY_IN_MILLIS,
currentTimeMillis = SOME_DAY_IN_MILLIS + MORE_THAN_TWO_MONTHS
)
}
it("should show 'rate us' again") {
Assert.assertTrue(showRateUsLogic.shouldShowRateUs())
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment