Ron Jeffries <ronjeffries / acm.org> writes:

> I noticed that RubyUnit is divided into one class or module per file.
> Some of the modules seem to be included only once.
> 
> The various files have a bunch of requires one to the other.
> 
> When using RubyUnit, it seems one has to write code like this:
> 
>   require 'runit/cui/testrunner'
>   RUNIT::TestCase.subclasses.each do | sc |
>     RUNIT::CUI::TestRunner.run(sc.suite)
>  end
> 
> with lots of :: and random names.

One use of modules is to help prevent namespace pollution. You pay for 
this with extra hassle when you actually _need_ the things defined in
that module.

However, you can tell Ruby: "hey, go ahead. pollute my name space. See
if I care" using 'include'


  include RUNIT
  include CUI

  TestCase.subclasses.each do |sc|
    TestRunner.run(sc.suite)
  end


Same things works with less complex Modules:

   Math.sin(1)		# => 0.8414709848
   include Math
   sin(1)		# => 0.8414709848

If you were developing a porn site, and had a method called 'sin',
you'd lose your sin :)



Dave