Okay, I have a custom taglib inside a custom taglib like so:
def preference = { attrs, body ->
def sliderTaglib = grailsApplication.mainContext.getBean('com.myCustom.sliderTagLib')
sliderTaglib.slider.call(attrs, body)
}
Since I am using grailsApplication.mainContext.getBean()
, how do i mock that in my unit test? My test complains:
grails Error executing tag No bean named is defined...
I've tried various methods to mock it but to no avail. It functions correctly when I run-app though, it's just the test that fails. I'm using grails 2.3.9 and spock. :(
My test looks like this:
void "taglib should output a slider"() {
when:
def result = applyTemplate("""
<a:preference class='slider'/>
""")
then:
result == "<div class='slider'></div>"
}