Grails single tag

I wrote a Grails tag, which is a very thin shell around the Grails select tag

package com.example

class MyTagLib {
  def listTrees = {attrs ->
    List<TreeDto> allTrees = getMandatoryAttributeValue(attrs, 'trees')
    out << g.select(from: allTrees)
  }
}

I wrote a unit test for this class, but when I run it, I get the following error while executing the last line:

groovy.lang.MissingMethodException: No method signature: com.example.MyTagLib.select () is applicable for argument types: (Java.util.LinkedHashMap)

It seems that the link to grails tags in the namespace is gnot available when doing unit tests. I tried to create an integration test instead, but this does not work either.

Is there a way to test a tag that calls another tag without interrupting / mocking the output of this other tag?

+3
source share
1

gral taglib, , metaClass.

protected void setUp() {
    super.setUp()
    mockTagLib(FormTagLib)
    def g = new FormTagLib()
    tagLib.metaClass.g = g
}
+7

All Articles