Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个无法开始工作的测试,所以我想通过打印响应来调试我的规范。
我已经尝试print response.body在我的规范中使用,但 test.log 或控制台中都没有输出。
print response.body
我可能错过了一些东西。我应该尝试什么?
谢谢!
您可以使用以下方法打印响应:
raise response.body
您可以使用
$stderr.puts response.body
打印您的回复。但我建议只使用上面的代码进行测试并从 RSpec 单元测试中删除任何放置,编写输出某些内容的 RSpec 代码被认为是不好的做法。
只需简单地使用
puts response.body