Skip to content

Instantly share code, notes, and snippets.

package com.igor
import org.codehaus.groovy.grails.validation.ConstrainedProperty
class GormTagLib {
static namespace = 'gorm'
/**
* Returns the max length of a field for a given domain.
package com.igor
import grails.test.mixin.*
import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
import spock.lang.Specification
import spock.lang.Unroll
@TestFor(GormTagLib)
class GormTagLibSpec extends Specification {
void "limit() should throw an exception if attributes are missing or wrong"() {
@ishults
ishults / gormTagLibSamples.html
Last active December 16, 2015 20:04
Sample usages
Maximum length: <span><gorm:limit clazz='com.igor.GormTagLibUser' field='username'/></span>
<input name='username' maxlength="${gorm.limit(clazz: 'com.igor.GormTagLibUser', field: 'username')}" />
Maximum length: <span>50</span>
<input name='username' maxlength='50' />
import spock.lang.Specification
class SampleSpec extends Specification {
def "example of power assert output"() {
when:
String first = 'The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.'
String second = '123The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog'
then:
assert [foo: first] == [foo: second]
customTestReportDir="/new/report/path"
eventTestSuiteEnd = {
if (config.customTestReportDir) {
junitReportStyleDir = config.customTestReportDir
}
}
@ishults
ishults / Grails_Groovy_Versions.txt
Last active June 14, 2024 08:39
List of Groovy versions for Grails
// Compiled by Igor Shults
// Last Updated: July 23, 2020
GRAILS GROOVY SOURCE
4.1.0 2.5.14 https://github.com/grails/grails-core/blob/v4.1.0/gradle.properties
4.0.4 2.5.6
4.0.3 2.5.6
4.0.2 2.5.6
4.0.1 2.5.6
4.0.0 2.5.6 https://github.com/grails/grails-core/blob/v4.0.0/build.gradle
@ishults
ishults / problem.groovy
Last active December 16, 2015 20:03
Introduction of the problem
void doSomething(def foo) {
println foo
}
void doSomethingElse(int bar) {
println bar
}
doSomething()
doSomethingElse() // Throws MissingMethodException
@ishults
ishults / anotherParam.groovy
Last active December 16, 2015 20:02
Adding a second parameter, even an optional one, means the no-arg method call will fail
void doSomething(def foo, def newParam = null) {
println foo
}
void doSomethingAgain(def baz, def newParam) {
println baz
}
doSomething() // Throws MethodSelectionException
doSomethingAgain('Test') // Throws MissingMethodException