Skip to content

Instantly share code, notes, and snippets.

@edysegura
Created December 3, 2014 13:19
Show Gist options
  • Save edysegura/ba3b5f90c17d06e705a7 to your computer and use it in GitHub Desktop.
Save edysegura/ba3b5f90c17d06e705a7 to your computer and use it in GitHub Desktop.
def "Should return the number of events for each month of all events"() {
given:
controller.eventService = Mock(EventService) {
historyReport() >> [
"2012": ["eventCount" : 6, "monthlyCount" : ["December" : 4, "November" : 1, "January" : 1]],
"2011": ["eventCount" : 3, "monthlyCount" : ["October" : 3]]
]
}
when:
controller.history()
then:
def result = JSON.parse(mockResponse.contentAsString)
result.size() == 2
result."2012" == ["eventCount" : 6, "monthlyCount" : ["December" : 4, "November" : 1, "January" : 1]]
result."2011" == ["eventCount" : 3, "monthlyCount" : ["October" : 3]]
and: "months are sorted"
mockResponse.contentAsString.indexOf("December") < mockResponse.contentAsString.indexOf("November")
mockResponse.contentAsString.indexOf("November") < mockResponse.contentAsString.indexOf("January")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment