PaulBarry.com - A Ruby Test Framework in One Line

screenshot

Time for a little Friday fun with Ruby. I love Ruby for things like this. I realize this has little practical usage, but the fact that it's possible says a lot about the language. You can build a test "framework" in one line of code in Ruby. Let's say we are going to write a method that take 0 to n arguments and adds them up. So following TDD, we write the tests first: tests = { "sum" => 0, "sum(7)" => 7, "sum(2, 3)" => 5, "sum(2, 3, 5)" => 10 } The tests are defined in a hash where the key is t...

http://paulbarry.com/articles/2008/05/23/a-ruby-test-framework-in-one-line
http://b.hatena.ne.jp/entry/http://paulbarry.com/articles/2008/05/23/a-ruby-test-framework-in-one-line