I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model.
#! /usr/bin/env ruby
require 'test/unit'
module Modulino
    def modulino_function
        return 0
    end
end
class ModulinoTest < Test::Unit::TestCase
    include Modulino
    def test_modulino_function
        assert_equal(0, modulino_function)
    end
end
Now, I can run the unit-tests executing this source file.
But, they are also run when I require/load them from another script. How can this be avoided ?
Is there a more idiomatic way to achieve this with Ruby, unless this practice is discouraged ?