dimanche 4 septembre 2016

Spock Testing when method under test contains closure

I'm using grails plugin multi-tenant-single-db. Within that context I need to write a spock test in which we temporarily remove the tenant restrictions. Location is my Tenant, so my method looks like this:

def loadOjectDetails(){
       Location.withoutTenantRestriction{
          // code here to retrieve specific items to the object to be loaded
          render( template: "_loadDetails", model:[ ... ]
       }
}

The method runs as expected, but trying to put method under test coverage the error output suggests that:

groovy.lang.MissingMethodException: No signature of method: com.myPackage.myController.Location.withoutTenantRestriction() is applicable for argument types: 

and a stacktrace that stems on from there.

Do I need to Stub this? The withoutTenantRestriction is a wrapper around my entire method logic.

Aucun commentaire:

Enregistrer un commentaire