

The latest code can be found on github? It's a merge with a previous version of DocTest? What did you add?









Aren't you satisfied with all the Ruby test frameworks?

Yes, that's the latest code. Earlier this week, I forked Tom Locke's project at github.com/tablatom/rubydoctest , and then merged my changes into his project once he gave permission. I found Tom's code to be very readable, and his approach to comparing results by evaling (rather than direct string testing, as in Python's doctests) was compelling. This allows ruby's unordered hashes to be compared successfully, for example. I also took Roger Pack's idea of putting doctests into comments right in the ruby source file. I didn't borrow any of Roger's code (at code.google.com ) but I borrowed his ideas. Now, Ruby DocTest gives the option of both the "inline doctest" style of Roger's package, with the "separate documentation in a markdown file" style of Tom's package.

Yes and no. I still like rspec quite a bit. But for my own workflow, I always find that I'm trying to catch up with the actual code written because I'm too lazy to switch to another file (or create a file) and write the tests. Often, I have this little niggling feeling that I should test some edge case of a method I'm working on, but I forego it because so many other things are on my mind at the time. If I could just put an irb session in there, I thought, that would cover 90% of my needs. So I did.



DocTest is outside the BDD cycle?







Is DocTest supposed to be a replacement for the other unit test framework or just an additional tool?

Yes, that's correct. This is not a test-first approach. My current needs, as mentioned above, are in documenting an already-existing project that is not well-tested.



Isn't the way DocTest annotates code polluting the reading?





I imagine the migration path of doctest to go something like this:





1. You write some code, and then add an inline doctest comment or two.

2. You make some other code modifications, and later come back to the original code.

3. You add more test cases, but the number of tests (or length) gets unwieldy, so you move them into a separate *.doctest file.

To be honest, I don't know yet. It's a new way of writing tests for me, so I'll be playing with it to find the answer soon. I imagine my 90% target above is close... there will probably be some places where it makes more sense to rely on traditional rspec or Test::Unit cases.