Ruby MiniTest:assert_equal的可读输出

时间:2012-06-18 15:13:56

标签: ruby minitest

是否有一种标准方法可以使assert_equal的失败输出更具可读性?

test "compare" do
  assert_equal "some string", "some string that differs"
end

这会产生:

MiniTest::Assertion: <"some string"> expected but was
<"some string that differs">.

理想情况下,输出会对齐,也可能会修剪以显示它们实际上的差异。对于小字符串,当前输出很好,但是当字符串很长时,很难辨别它们的不同之处。

1 个答案:

答案 0 :(得分:0)

MiniTest有一个diff()方法返回diffing工具。你也可以设置它。请参阅此文档。

module MiniTest::Assertions