Skip to content

Instantly share code, notes, and snippets.

@norman
Created March 30, 2011 01:06
Show Gist options
  • Save norman/893678 to your computer and use it in GitHub Desktop.
Save norman/893678 to your computer and use it in GitHub Desktop.
require "test/unit"
Module.send :include, Module.new {
def test(name, &block)
define_method("test_#{name.gsub(/[^a-z0-9]/i, "_")}".to_sym, &block)
end
alias :should :test
}
module NumericTests
test "should do addition" do
assert_equal 2, @this + 1
end
end
class IntegerTest < Test::Unit::TestCase
include NumericTests
def setup
@this = 1
end
end
class FloatTest < Test::Unit::TestCase
include NumericTests
def setup
@this = 1.0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment