This file contains 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
// Setup | |
private mockTagLibRender() { | |
tagLib.metaClass.render = { Map attrs -> | |
render = attrs | |
} | |
} | |
// Utilization | |
given: | |
mockTagLibRender() |
This file contains 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
libraryDependencies += "org.scalatest" % "scalatest 2.10" % "2.1.0" % "test" |
This file contains 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
import grails.test.mixin.Mock | |
import grails.test.mixin.TestFor | |
import spock.lang.IgnoreRest | |
import spock.lang.Specification | |
import spock.lang.Unroll | |
@Unroll | |
@TestFor(UrlMappings) | |
@Mock([MockYourController]) | |
class UrlMappingsSpec extends Specification { |
This file contains 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
log4j = { | |
... | |
debug 'org.hibernate.SQL' | |
trace 'org.hibernate.type.descriptor.sql.BasicBinder' | |
} |
This file contains 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
@TestFor(MyQuartzJob) | |
@TestMixin(ControllerUnitTestMixin) // This allows access to grailsApplication | |
class MyQuartzJobSpec extends Specification { | |
def job | |
def setup() { | |
grailsApplication.config.some.config.stuff = true | |
job = new MyQuartzJob() | |
} | |
} |
This file contains 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
// Templates rendered by TagLib may be verified as follows | |
class SomeAwesomeSpec extends Specification { | |
public static final String BLAH = "BLAH" | |
void "test something"() { | |
given: | |
groovyPages.put("/path/to/_blah.gsp", BLAH) | |
when: |
This file contains 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
Collections.emptyList() | |
// Use Collections.emptyList() when you do not wish to modify the returned list, otherwise [] | |
// That's what you use if you want to pass a default parameter that will not be modified by the called funciton | |
// http://stackoverflow.com/questions/5552258/collections-emptylist-vs-new-instance |
This file contains 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
// Convert | |
myCoolemailService.myEmailService = Mock(MyEmailService) | |
// to | |
myCoolemailService.myEmailService = Mock([useObjenesis: false], MyEmailService) |
This file contains 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
import org.hibernate.criterion.CriteriaSpecification | |
BlogEntry.withCriteria { | |
maxResults 5 | |
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP) | |
projections { | |
count('id', 'total') | |
groupProperty('author', 'author') | |
} | |
} |
This file contains 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
//grails.project.class.dir = "target/classes" | |
//grails.project.test.class.dir = "target/test-classes" | |
//grails.project.test.reports.dir = "target/test-reports" | |
grails.project.work.dir="target" |
NewerOlder