Ruby 中的文档作为测试?

Documentation as tests in Ruby?

有一个很棒的工具 rustdoc(目前被 cargo) to test examples of documentation comments in Rust 使用。在 Ruby 中,rdoc 或 yard 是否为我们提供了类似的东西?

嗯,Ruby 中的 doctest 工具示例很少,最新鲜的(目前)是 yard-doctest:

Meet YARD::Doctest - simple and magical gem, which automatically parses your @example tags and turn them into tests!

可能没有 rustdoc 强大,但它可以满足需要。