On 6/26/07, Galevsky gal <galevsky / gmail.com> wrote:

>
> I do it now with a class extension instead of module inclusion due to
> limitations, even if mixin best suits the needs INMHO.

Hmm I am quite sure Mixin will do the trick, why should we let you
have all the fun ;)


module Tester
    def self.extended other
      registry =
other.instance_methods.select{|name|/^test/===name}.map{|mth|
other.instance_method mth}
      class << other; self end.send :define_method, :run_tests do
        | msg |
        puts "running #{msg}"
        registry.each do |mth|
          mth.bind(other.new).call
        end
      end
    end
end

class TestWhatever
  def test_a; puts "I am tested" end
  extend Tester
end

class TestSomethingElse
  def test_b; puts "Me too" end
  extend Tester
end

TestWhatever.run_tests :whatever
TestSomethingElse.run_tests :something

Robert
-- 
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw