Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Abort Heckle if supplied method doesn't exist

[git-p4: depot-paths = "//src/heckle/dev/": change = 3005]
  • Loading branch information...
commit c2e16478fc33bee4e268c0a321a4da450a64f3f2 1 parent af5a6fb
@kevinclark kevinclark authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/test_unit_heckler.rb
View
13 lib/test_unit_heckler.rb
@@ -21,6 +21,16 @@ def self.validate(klass_name, method_name = nil)
load_test_files
klass = klass_name.to_class
+ # Does the method exist?
+ klass_methods = klass.singleton_methods(false).collect {|meth| "self.#{meth}"}
+ if method_name
+ if method_name =~ /self\./
+ abort "Unknown method: #{klass_name}.#{method_name.gsub('self.', '')}" unless klass_methods.include? method_name
+ else
+ abort "Unknown method: #{klass_name}##{method_name}" unless klass.instance_methods(false).include? method_name
+ end
+ end
+
initial_time = Time.now
unless self.new(klass_name).tests_pass? then
@@ -38,8 +48,7 @@ def self.validate(klass_name, method_name = nil)
self.timeout = adjusted_timeout
puts "Initial tests pass. Let's rumble."
-
- klass_methods = klass.singleton_methods(false).collect {|meth| "self.#{meth}"}
+
methods = method_name ? Array(method_name) : klass.instance_methods(false) + klass_methods
results = methods.map do |method_name|
Please sign in to comment.
Something went wrong with that request. Please try again.