From: "David A. Black" Date: 2005-09-04T02:48:37+09:00 Subject: Re: Newbie Q: Self-Testing Ruby Files (Double Assignment to Constants) Hi -- On Sun, 4 Sep 2005, ded wrote: > I like to make class files self-testing and can do so with the > following arrangement: > > ==================== Junk.rb ========================== > Class Junk class, not Class :-) > CONST = 'a value' > def initialize > end > end > > # Unit tests > if __FILE__ == $0 > require 'test/TestJunk.rb' > end > > ===================== test/TestJunk.rb ================== > require 'test/unit' > require 'Junk' unless defined?(CONST) You've defined CONST inside Junk, but you're testing for it at the top level. Try this: require 'Junk' unless defined?(Junk::CONST) David -- David A. Black dblack@wobblini.net