I have to write code for an homework and I wish to do TDD from the start.
The homework consists of one ruby file with methods in it, no class.
All examples I find on the Internet test against classes. How could I test the following method?
homework.rb
#!/usr/bin/env ruby
def count_words(str)
# SOME CODE HERE
end
There is an auto-grading system that take one ruby file with the methods defined for the homework as an input. So, I have to write my tests in a separate file (test_homework.rb) or comment out my test before submitting (which I found counter productive…).
How will I test the count_words method using Test:Unit?
Do something like this: