Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1

Implementing a Rules DSL


[ 306 ]

then:
account.points == expected

when:
bbPlus.consume(account, terminator)

then:
account.points == expected - terminator.points
}
def "Rental extension reward"() {
given:
bbPlus.consume(account, up)
bbPlus.consume(account, terminator)
def now = new Date()
expect: "Extension applied to Up but not Terminator"
account.getMediaExpiry(up).after(now + 1)
account.getMediaExpiry(
terminator).after(now + 1) == false
}
def "Purchase reward applied to Games"() {
expect:
account.points == 120

when:
bbPlus.purchase(account, terminator)
bbPlus.consume(account, terminator)
then:
account.points == 120
when:
bbPlus.purchase(account, halo1)
bbPlus.consume(account, halo1)
then:
account.points == 122

}

def "Upgrade to plus reward"() {
expect:
account.points == 120

when:
bbPlus.upgrade(account, "PLUS")
then: "Should have 250 for PLUS and 100 bonus"

http://www.ebook3000.com
Free download pdf