Forum: Ruby Re: how to test a ruby class

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Gennady B. (Guest)
on 2006-02-10 21:15
(Received via mailing list)
You can do

=== some-class.rb
class SomeClass

if $0 == __FILE__
  c =

This way the code in the 'if' block will be executed only when you do
$ ruby some-class.rb

It will not be executed when you require some-class.rb from some other
ruby file.

This topic is locked and can not be replied to.