控制器规范失败并显示 501 未实现状态
我正在尝试向我开始开发的旧应用程序添加测试,但我失败了:(
这是一个带有 Rspec 1.3.2 和 Rspec-rails 1.3.4 的 Rails 2.3.8 应用程序。
这就是我所拥有的一切现在在控制器规范上:
before(:each) do
@attributes = { ... }
end
it 'should create a notification' do
post 'create', :notification => @attributes
assigns[:notification].should_not be_new_record
end
我花了几个小时试图找出为什么没有设置 @notification
变量,我刚刚发现响应是 501 Not一直以来都已实现...
当然,控制器在浏览器中工作得很好,所以我一生都无法弄清楚为什么会出现该错误。
有什么想法吗?
I'm trying to add tests to an old app I started working on, but I'm failing miserably :(
It's a Rails 2.3.8 app with Rspec 1.3.2 and Rspec-rails 1.3.4.
This is all I have right now on a controller spec:
before(:each) do
@attributes = { ... }
end
it 'should create a notification' do
post 'create', :notification => @attributes
assigns[:notification].should_not be_new_record
end
I spent hours trying to figure out why the @notification
variable wasn't being set, and I just found out the response has been 501 Not Implemented
all this time...
Of course the controller works fine from a browser, so for the life of me I can't figure out why I'm getting that error.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,我忘记克隆测试数据库,因此我分配的一些属性不在测试数据库上,因此出现错误。
我是在想起
log/test.log
存在后才发现的……我很高兴没有人先回答,否则我会更尴尬:DBah, I forgot to clone the test database so some of the attributes I was assigning weren't on the test DB, and thus the error.
I only found out after I remembered
log/test.log
exists... I'm glad nobody answered first or I'd be even more embarrased :D