Skip to content

Instantly share code, notes, and snippets.

@pphetra
Created February 17, 2012 13:01
Show Gist options
  • Save pphetra/1853291 to your computer and use it in GitHub Desktop.
Save pphetra/1853291 to your computer and use it in GitHub Desktop.
description "Request an interest rate from interest service"
before "prepare helper function", {
prepareRate = { params->
}
date = { str ->
}
}
given "rate between 2011-01-01 and 2011-11-01 is 5%", {
prepareRate(
from: '2011-01-01',
to: '2011-11-01',
rate: 5.00
)
}
given "rate between 2011-11-02 and 2011-12-31 is 7%", {
prepareRate(
from: '2011-01-01',
to: '2011-11-01',
rate: 5.00
)
}
scenario "Request interest rate with valid date", {
when "request for an interest rate on '2011-01-01'", {
rate = interestService.getRate(date('2011-01-01'))
}
then "rate should be 5%", {
rate.shoudBe(5.00)
}
when "request for an interest rate on '2011-12-20'", {
rate = interestService.getRate(date('2011-12-20'))
}
then "rate should be 7%", {
rate.shouldBe(7.00)
}
}
scenario "Request interest rate with invalid date", {
when "request for an interest rate on '2001-01-01'", {
exceptionOccur = false
try {
rate = interestService.getRate(date('2001-12-20'))
} catch (e) {
exceptionOccur = true
}
}
then "service should throw an exception", {
assertTrue(exceptionOccur)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment