Forum: Ruby using testrb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John M. (Guest)
on 2006-03-02 19:52
(Received via mailing list)
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:-

jayeola@acid$ 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:-
jayeola@acid$ ruby fact.rb 44
2658271574788448768043625811014615890319638528000000000

using testrb:-

jayeola@acid$ 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:in `collect_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:in `collect'
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:in `run'
from /usr/bin/testrb:5
Mark V. (Guest)
on 2006-03-02 20:20
(Received via mailing list)
On 3/2/06, John M. <removed_email_address@domain.invalid> wrote:
>     f *= i
>
> jayeola@acid$ 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".
This topic is locked and can not be replied to.