# File lib/test_unit_heckler.rb, line 27 27: def self.focus=(value) 28: @@focus = value 29: end
# File lib/test_unit_heckler.rb, line 31 31: def self.load_test_files 32: @@tests_loaded = true 33: Dir.glob(@@test_pattern).each {|test| require test} 34: end
# File lib/test_unit_heckler.rb, line 101 101: def initialize(klass_name=nil, method_name=nil, nodes=Heckle::MUTATABLE_NODES) 102: super 103: self.class.load_test_files unless @@tests_loaded 104: end
# File lib/test_unit_heckler.rb, line 23 23: def self.test_pattern=(value) 24: @@test_pattern = value 25: end
# File lib/test_unit_heckler.rb, line 36 36: def self.validate(klass_name, method_name = nil, 37: nodes = Heckle::MUTATABLE_NODES, force = false) 38: load_test_files 39: klass = klass_name.to_class 40: 41: # Does the method exist? 42: klass_methods = klass.singleton_methods(false).collect {|meth| "self.#{meth}"} 43: if method_name 44: if method_name =~ /self\./ 45: abort "Unknown method: #{klass_name}.#{method_name.gsub('self.', '')}" unless klass_methods.include? method_name 46: else 47: abort "Unknown method: #{klass_name}##{method_name}" unless klass.instance_methods(false).include? method_name 48: end 49: end 50: 51: initial_time = Time.now 52: 53: heckle = self.new(klass_name) 54: 55: passed = heckle.tests_pass? 56: 57: unless force or passed then 58: abort "Initial run of tests failed... fix and run heckle again" 59: end 60: 61: if self.guess_timeout? then 62: running_time = Time.now - initial_time 63: adjusted_timeout = (running_time * 2 < 5) ? 5 : (running_time * 2).ceil 64: self.timeout = adjusted_timeout 65: end 66: 67: puts "Timeout set to #{adjusted_timeout} seconds." 68: 69: if passed then 70: puts "Initial tests pass. Let's rumble." 71: else 72: puts "Initial tests failed but you forced things. Let's rumble." 73: end 74: puts 75: 76: methods = method_name ? Array(method_name) : klass.instance_methods(false) + klass_methods 77: 78: counts = Hash.new(0) 79: methods.sort.each do |method_name| 80: result = self.new(klass_name, method_name, nodes).validate 81: counts[result] += 1 82: end 83: all_good = counts[false] == 0 84: 85: puts "Heckle Results:" 86: puts 87: puts "Passed : %3d" % counts[true] 88: puts "Failed : %3d" % counts[false] 89: puts "Thick Skin: %3d" % counts[nil] 90: puts 91: 92: if all_good then 93: puts "All heckling was thwarted! YAY!!!" 94: else 95: puts "Improve the tests and try again." 96: end 97: 98: all_good 99: end
# File lib/test_unit_heckler.rb, line 108 108: def tests_pass? 109: silence_stream do 110: if @@focus and @method_name then 111: name = normal_to_test @method_name.to_s 112: ARGV.clear 113: ARGV << "--name=/#{name}/" 114: end 115: result = Test::Unit::AutoRunner.run 116: ARGV.clear 117: result 118: end 119: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.