Sha256: e2df8629c5ba1e920c41df2f568e2b087eb98900209caf3d5c790dc364b9d532
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 Bytes
Contents
require 'test/unit' require 'facet/consoleapp' # Run commented tests. # #-- # One wonders if this should be built as a Test::Unit::CommentAutoRunner #++ class RubyCommentTester < Console::Command RETEST = /^=begin\s+test.*?\n(.*)\n=end/mi # option to display help def __verbose ; $VERBOSE = true ; end alias_method :_v, :__verbose # option to display help def __help puts HELP exit 0 end alias_method :_h, :__help def main( *filepaths ) filepaths.each { |fp| run_comment_test( fp ) } end private def run_comment_test( filepath ) code = File.read( filepath ) test_code = nil md = RETEST.match( code ) test_code = md[1] if md unless test_code puts "No test found for #{filepath}." return nil end offset = code.split(/\n/).size - test_code.split(/\n/).size - 1 require filepath eval test_code, TOPLEVEL_BINDING, File.basename(filepath), offset end end HELP = <<-EOS rubytest filename [filename ...] EOS
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reap-6.0.2 | lib/reap/bin/rubytest.rb |