Rails 3.1,固定装置和测试问题
所以,我在 Rails 中运行测试时遇到了一些问题。当我运行“Rake test”并且我的控制器内部有类似的内容时
http_basic_authenticate_with :name =>Hello.first.myhello, :password =>Hello.first.myhello
,我收到错误
“method_missing”:未定义的方法“myhello” for nil:NilClass(NoMethodError)
显然,装置没有被加载,无论如何我可以让它们加载并且不会失败吗?使用 Rails 3.1。
So, I am having some trouble running tests in Rails. When I ran 'Rake test' and I have something like this
http_basic_authenticate_with :name =>Hello.first.myhello, :password =>Hello.first.myhello
Inside my controller, I get an error
'method_missing': undefined method `myhello' for nil:NilClass (NoMethodError)
Clearly the fixtures aren't being loaded, is there anyway I can make them load and have this not fail? Using Rails 3.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
** 编辑: 可能相关的问题/答案?基本上,将其放入您的测试单元类中:
如果这不起作用,您可以粘贴固定装置和测试类的相关部分吗?
**原文:
我不确定您的经验水平或您的设置,因此为了确认您正在测试您认为正在测试的内容,您可以在问题中的行之前添加此行吗?
如有任何混淆,
表示您实际上没有获取任何记录,而不是您没有 Hello 模型。
** edit: possibly related SO question/answer? Basically, put this in your test unit class:
If that doesn't do it, could you paste the relevant parts of your fixture and test class?
**original:
I'm not sure about your experience level or your setup, so just to confirm that you are testing what you think you are testing, could you add this line before the line in your question?
In case there is any confusion,
indicates that you are not actually getting any records, not that you don't have the Hello model.