TDD is NOT about achieving 100% test coverage (which IMO is
meaningless). TDD is about using test to drive development.More
specifically, TDD requires three equally important types of
activities: - writing test - writing the simplest code that
passes the test - refactoring code that keeps tests passing
First the test: describe 'alert' do it 'should log the message'
do logger.should_receive(:info).with('a message');
subject.alert('a message'); end endThen the method in tested
class: def alert(msg) logger.info(msg) endThen you are done with
this method. This is NOT TDD. First, you didn't refactor the
code. Second, it's not likely that the test will help when you
need to refactor this code in the future. In one sentence, the
refactor-and-keep-tests-green part is missing. So what will a
TDDer do here? Simply write the code without the test. A typical
argument against it is that what if some other developer
accidentally delete the logger.info(msg) code? Well, that's not
the purpose of TDD, that is what version con