1

I have a test where the gsp uses the Asset Pipeline tag assetPath, in grails 2 I had no issues but in grails 3 I'm getting an org.grails.taglib.GrailsTagException: [SOME_GSP.gsp:184] Error executing tag <g:form>: Error evaluating expression [assetPath(src: 'SOME_PDF.pdf')] on line [60]: No signature of method: SOME_GSP_gsp.assetPath() is applicable for argument types: (java.util.LinkedHashMap) values: [[src:SOME_PDF.pdf]]

Grails 3.1.6

Example test file:

@TestMixin(GroovyPageUnitTestMixin)
class SomeTests extends Specification {

    void "ssn is not returned to the SOME_GSP page"() {
        given:
        def cmd = new commandObject(SOME_FIELD: 'data')

        when:
        def renderedView = render(view: 'SOME_GSP', model: [cmd: cmd])

        then:
        assert !renderedView.contains('data')
    }
}
Lifeweaver
  • 986
  • 8
  • 29

1 Answers1

2

Turns out I needed to mock certain classes:

@Mock([AssetsTagLib, AssetMethodTagLib, AssetProcessorService])

And to get the classes to resolve I needed to add a testCompile dependency to my build.gradle

testCompile "com.bertramlabs.plugins:asset-pipeline-grails:2.9.4"
Lifeweaver
  • 986
  • 8
  • 29