使用 Tower 0.4.2-20:我已经按照示例进行了操作,所有代码似乎都已生成,但在运行测试时出现工厂未定义错误。
更加具体:
tower new app
cd app
npm install
tower generate scaffold Post title:string body:text
tower generate scaffold User firstName:string lastName:string email:string
npm test
产量:
1) PostsController routes show:
actual expected
/posts/undefined
2) PostsController routes edit:
actual expected
/posts/undefined/edit
3) PostsController #index "before each" hook:
Error: Factory 'post' doesn't exist.
at Function.Tower.Factory.options [as get] (/home/jeremy/repos/tower/lib/tower-support/shared/factory.js:84:13)
at Function.Tower.Factory.factory [as create] (/home/jeremy/repos/tower/lib/tower-support/shared/factory.js:73:17)
at global.factory (/home/jeremy/test/towapp/test/server.coffee:21:42)
at Context.get.format (/home/jeremy/test/towapp/test/cases/controllers/server/postsControllerTest.coffee:46:16)
at Hook.Runnable.run (/home/jeremy/test/towapp/node_modules/mocha/lib/runnable.js:187:15)
at next (/home/jeremy/test/towapp/node_modules/mocha/lib/runner.js:201:10)
at Runner.hook (/home/jeremy/test/towapp/node_modules/mocha/lib/runner.js:212:5)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
我尝试自己调试它,并从 Github 构建了 Tower 并链接到那个,正如您在上面看到的那样,它正在使用我的存储库版本的 Tower 代码,但我也被困在那里。我不确定制作调试打印/记录语句的正确方法;我已经尝试过 console.log 和 this.debug.log ,在这两种情况下,都没有将日志消息写入控制台或日志文件 - 事实上,日志目录中根本没有创建任何日志。
编辑添加:取得了更多进展。未调用 Tower.Factory.define 方法。Factory 类确实存在:
Tower.Factory.define 'post', ->
title: Tower.random('words')