有没有办法让 RSPec 的错误消息更具洞察力?

发布于 2024-11-15 03:47:25 字数 245 浏览 7 评论 0原文

在尝试调试时,我经常不知所措,因为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里的微风 2024-11-22 03:47:25

测试框架通常允许您断言实际结果等于预期结果,并且当断言失败时,将打印出断言以及预期结果和实际结果。

他们无能为力。您似乎正在寻找软件方面的神奇直觉。

尝试如下操作:

response.status_code.should == 200

这会将实际的 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:

response.status_code.should == 200

This compares the actual status_code with the expected status_code, asserting their equality, and printing both if the assertion fails.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文