Created
May 13, 2011 14:41
-
-
Save rfreedman/970650 to your computer and use it in GitHub Desktop.
Spock Integration Test for Grails Controller Example
This file contains hidden or 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
class CompoundInstanceControllerIntegrationSpec extends ControllerSpec { | |
static transactional = true | |
def "saving a new compound instance and compound"() { | |
setup: | |
controller.metaClass.message = {args -> "mockMessage"} | |
when: | |
controller.params.compound = compoundArgs | |
controller.params.compoundInstance = compoundInstanceArgs | |
controller.params.compoundNamesJson = compoundNamesJsonArg | |
SpringSecurityUtils.doWithAuth('superuser') { | |
controller.save() | |
} | |
then: | |
controller.redirectArgs.action == "show" | |
controller.redirectArgs.id > 0 | |
def compoundInstance = CompoundInstance.load(controller.redirectArgs.id) | |
compoundInstance.primaryName == "one" | |
compoundInstance.compoundNames.size() == 3 | |
compoundInstance.compound.chemicalName == "aChemical" | |
where: | |
compoundArgs = ['chemicalName': "aChemical"] | |
compoundInstanceArgs = ['programContact.id' : SecUser.findByUsername('superuser').id ] | |
compoundNamesJsonArg = '[["one",true,""],["two",false,""],["three",false,""]]' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment