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.