Using testrb

My script works but testrb is giving me some error messages. I’ve just
come across unit testing yestarday so I’m quite new to this. What do
these error messages mean and why does the script not run?

A sample script:-

[email protected]$ cat fact.rb
def fact(n)
return 1 if n == 0
f = 1
n.downto(1) do |i|
f *= i
end
return f
end
print fact(ARGV[0].to_i), “\n”

sample usage:-
[email protected]$ ruby fact.rb 44
2658271574788448768043625811014615890319638528000000000

using testrb:-

[email protected]$ testrb ruby fact.rb 4
/usr/lib/ruby/1.8/test/unit/collector/dir.rb:83:in require': no such file to load -- ruby (LoadError) from /usr/lib/ruby/1.8/test/unit/collector/dir.rb:83:incollect_file’
from /usr/lib/ruby/1.8/test/unit/collector/dir.rb:70:in
recursive_collect' from /usr/lib/ruby/1.8/test/unit/collector/dir.rb:30:incollect’
from /usr/lib/ruby/1.8/test/unit/collector/dir.rb:29:in collect' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:67 from /usr/lib/ruby/1.8/test/unit/autorunner.rb:198:inrun’
from /usr/bin/testrb:5

On 3/2/06, John M. [email protected] wrote:

f *= i

[email protected]$ testrb ruby fact.rb 4
/usr/lib/ruby/1.8/test/unit/collector/dir.rb:83:in `require’: no such
file to load – ruby (LoadError)

It can’t find a file to load named “ruby”.
Try running “testrb fact.rb 4”.