- 圣杯 2.2.4
- 斯波克 0.7
我正在尝试测试是否从 grails 控制器呈现了正确的视图。我的创建方法如下所示:
def create() {
def documentCategories = DocumentCategory.list()
def documentTypes = DocumentType.list()
def documentComponents = DocumentComponent.list()
[documentCategories: documentCategories,
documentTypes: documentTypes,
documentComponents:documentComponents]
}
我的测试:
def "test create action"() {
given:
def model = controller.create()
expect:
response.status == 200
model.documentCategories.size() == 0
model.view == '/document/create'
}
我尝试了各种版本,model.view
包括:
view == '/document/create'
response.forwardedUrl == '/document/create'
所有这些都失败了,因为model.view
,view
和response.forwardedUrl
都为空。建议?