You can do

=== some-class.rb
class SomeClass
...
end 

if $0 == __FILE__
  c = SomeClass.new
  c.whatever_method_you_want_to_test
end

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.

Gennady.

> -----Original Message-----
> From: doug.baker / ficoh.com [mailto:doug.baker / ficoh.com] 
> Sent: Friday, February 10, 2006 11:08
> To: ruby-talk ML
> Subject: how to test a ruby class
> 
> > Hi:  I just installed Ruby and have FreeRIDE open.  In 
> Ruby, is there 
> > a method comparable to the "main" method in java that will run the 
> > class for testing?
> > I would like to run my class from the IDE.
> > 
> > Thanks,
> > Doug
> > 
> > 
> E-MAIL CONFIDENTIALITY NOTICE:
> The contents of this e-mail message and any attachments are 
> intended solely for the addressee(s) and may contain 
> confidential and/or legally privileged information.  If you 
> are not the intended recipient of this message or if this 
> message has been addressed to you in error, please 
> immediately alert the sender by reply e-mail and then delete 
> this message and any attachments.
> If you are not the intended recipient, you are notified that 
> any use, dissemination, distribution, copying, or storage of 
> this message or any attachments is strictly prohibited. 
>