Yesterday, a colleague of mine was having problems with an image. It seems that the code she was using, and had always used to insert an image was not working. After a quick look, there was an extra space in the code that was preventing the IMG-tag from properly rendering. (Note: the site uses Textile to manage it’s content; So an extra space means the Textile to HTML parser may encounter problems).
I poked around in the code for a bit, wanting to ensure that Conductor was not “helping” her by inserting an extra space…This did appear to be the case; And according to my colleague, she had in fact hit the space bar. As a general rule, the system should prevent bad data from being entered. So I updated the system to remove any trailing spaces. As is typical, when I make a change to the code, I write a test that first fails. Then I update the code, and get the test to pass. After all, I can’t verify something is fixed unless I can first verify it is broken.
This fix was proving to be a bit cantankerous. The test was failing in a slightly unexpected way. And then it struck me… While I was looking and updating the code to prevent the extra spacing from causing a problem, I had stumbled upon another problem. So, I dug in, and found, to my elation, the root cause of a long-standing, erratic bug that I had been chasing around, but never successfully squashing.
I cleaned up the first test that was failing, and wrote a second test to duplicate the behavior that was causing the long standing error. This second test didn’t initially pass, but I knew I was on the right path. So I tweaked my test, and was ecstatic when the test failed. After all, I had to verify that it was failing before I could fix it. I then stepped into the code, and fixed the problem. And the test succeeded! Which meant that my test now verified the expected behavior.
What started out as ensuring proper data, even accidentally entered, became a fix for a long standing problem. Incidentally, my colleague was also a sem-regular “victim” of the long standing problem.
Carol, thanks for hanging in there with me as we muddled through this problem.