The following constellation in a unit test returns: No such property: title for class: myproject.Item Possible solutions: title
ItemController.groovy
def add = {
[itemInstance: new Item(), titleMin: Item.constraints.title.size.min() ]
}
ItemControllerSpec.groovy
mockDomain Item
def result = controller.add()
How can I mock out that constraints line?
Note: I just want the test to run instead of failing due to that line.
Via metaClass. In
setUp(), write something like:Item.metaClass.'static'.constraints = [ title: [ size: [ min: {5}, max: {30} ] ] ]