From: Ben Giddings Date: 2005-05-07T03:48:54+09:00 Subject: Re: Typo-checking instead of static typing On Wednesday 04 May 2005 15:36, Joost Diepenmaat wrote: > On Thu, May 05, 2005 at 03:49:30AM +0900, Ben Giddings wrote: > [ snip ] > > > def do_something(foo) > > if foo > 500 > > puts "Whoa, #{fo} is too many times! I can't do that!" > > else > > foo.times { |i| puts i } > > end > > end > > > > do_something(ARGV[0]) > > Use a code coverage tool to run over your unit tests, and fix your > tests to go to 100% coverage. That's what I usually try to do in Perl anyway. > > Pointers to coverage tools for ruby anyone? I sent an email reply to this, but nobody followed up, but I'm really interested to hear the answer. The suggestion here was to write unit tests to make sure that the line with the typo is caught ("Whoa, #{fo} ..." instead of "Whoa, #{foo} ...") My question is this. If the "Ruby Way" to find this bug is by unit tests, what suite of tests would be recommended for this snippet of code? Keep in mind, that the original code is only 8 lines long. Is it realistic to expect that someone would write more than 8 lines of unit tests? Ben