Aspiring to be a good programmer, I'm using Test::Unit for ClothRed, 
writing the test before I write the code, even.

Which is all well and good, but I have a test, that produces an error 
*while it is executed* and *not* in the error report:

test_textformatting(TestClothRedFormatting):
TypeError: can't convert nil into String
     ../test/../lib/clothred.rb:22:in `gsub!'
     ../test/../lib/clothred.rb:22:in `to_textile'
     ../test/../lib/clothred.rb:21:in `collect!'
     ../test/../lib/clothred.rb:21:in `to_textile'
     ../test/test_formatting.rb:43:in `test_textformatting'
     ../test/test_formatting.rb:41:in `each'
     ../test/test_formatting.rb:41:in `test_textformatting'

2 tests, 1 assertions, 0 failures, 1 errors

My tests look like this:

   #Works:
   def test_tags
     assert_equal("**bold**", ClothRed.new("<b>bold</b>").to_textile)
   end

   #Doesn't work:
   def test_textformatting
     FORMATTING_STRINGS.each do |html, textile|
       test_html = ClothRed.new(html)
       test_html.to_textile
       assert_equal(textile,test_html)
     end
   end

The Array is as follows:

   FORMATTING_STRINGS = [
     ["<b>bold</b>","**bold**"], ["<strong>strong</strong>", "*strong*"],
     ["<em>emphasized</em>", "_emphasized_"],
     ["<i>italics</i>", "__italics__"],
     ["<cite>citation</cite>", "??citation??"],
     ["<code>ClothRed#to_textile</code>", "@ClothRed#to_textile@"],
     ["<del>delete</del>", "-delete-"],
     ["<ins>underline</ins>", "+underline+"],
     ["<sup>superscript</sup>","^superscript^"],
     ["<sub>subscript</sub>","~subscript~"]
   ]


An improvised test run produces this:

c:\test.rb
**bold**
_emphasized_
__italics__

c:\cat test.rb
# test.rb
# 11. April 2007
#

require 'clothred'



TEST = '<b>bold</b>
<em>emphasized</em>
<i>italics</i>'

test = ClothRed.new(TEST)

puts test.to_textile


My Ruby version:
c:\ruby -v
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]

The output of the test suggests, that I'm doing something wrong in my 
test, that my test is buggy, and not my code.

Can somebody enlighten me?

-- 
Phillip "CynicalRyan" Gawlowski
http://cynicalryan.110mb.com/

Rule of Open-Source Programming #6:

The user is always right unless proven otherwise by the developer.