Skip to content

Instantly share code, notes, and snippets.

@ddelponte
Created July 19, 2016 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddelponte/b0d27754d1bee2bdb5ac75b709b1cd56 to your computer and use it in GitHub Desktop.
Save ddelponte/b0d27754d1bee2bdb5ac75b709b1cd56 to your computer and use it in GitHub Desktop.
Mock out the render method on a tagLib so that it's easy to verify the template and model utilized by the tagLib when rendering
// Setup
private mockTagLibRender() {
tagLib.metaClass.render = { Map attrs ->
render = attrs
}
}
// Utilization
given:
mockTagLibRender()
CoolThing coolThing = new CoolThing()
when:
tagLib.renderCoolThing(
now: "now",
derp: "derp"
)
then:
render.template == "this/template/is/used/to/render"
render.model.now == "now"
render.model.derp == "derp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment