Doctest in Python is a good design. Doctest ensures code, documentation, and tests are in a single place. So readers can understand the logic of code easier, without a lot of navigation.
Unlike Python, Ruby does not have built-in doctest, but there are some third party libraries enabling doctest in Ruby.