我在自定义标记库中有一个方法,如下所示:
def deleteAction = {attrs ->
def id = attrs['id']
def type = attrs['type']
def clazz = attrs['class']
def html = new MarkupBuilder(out)
html.span(class: "${clazz} ui-icon ui-icon-trash {id:'${id}'}")
}
我有一个使用这种方法的控制器,我试图将它存根进行单元测试,所以我有以下内容:
def mockMyTagLib = mockFor(MyTagLib)
mockMyTagLib.demand.deleteAction(1) {id, type, clazz ->
def html = new MarkupBuilder(new StringWriter())
html.span(class: "${clazz} ui-icon ui-icon-trash {id:'${id}'}")
}
controller.metaClass.mn = mockMyTagLib.createMock()
但我不断收到以下信息:
此时不再需要调用“deleteAction”。要求结束。
我在这里做错了吗?这是它在控制器中的实际用法:
"${mn.deleteAction(id: it.id, type: 'bookProduct', 'class': 'del-book-product')}"