有没有办法让 RSPec 的错误消息更具洞察力?
在尝试调试时,我经常不知所措,因为 RSpec 只告诉我这一点
expected redirect to "/user_session/new", got no redirect
expected success? to return true, got false.
,但由于它没有告诉我发生了什么,而是很难调试,
所以这是 RSpec 内置的东西并且无法更改,还是它是一个配置的东西某种。
I am often at a loss when trying to debug, since RSpec only tells me that
expected redirect to "/user_session/new", got no redirect
expected success? to return true, got false.
but since It doesnt tell me what happened instead its hard to debug,
so is this something built in to RSpec and cannot be changed or is it a configuration thing of some kind.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
测试框架通常允许您断言实际结果等于预期结果,并且当断言失败时,将打印出断言以及预期结果和实际结果。
他们无能为力。您似乎正在寻找软件方面的神奇直觉。
尝试如下操作:
这会将实际的
status_code
与预期的status_code
进行比较,断言它们相等,并在断言失败时打印两者。Test frameworks generally permit you to assert that an actual result is equal to an expected result, and when that assertion fails, will print out the assertion as well as the expected and actual results.
There's not much more they can do. What you seem to be looking for is magical intuition on the part of software.
Try something like:
This compares the actual
status_code
with the expectedstatus_code
, asserting their equality, and printing both if the assertion fails.