1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test/unit.rb: regexps to exclude

* test/lib/test/unit.rb (ExcludedMethods#exclude_from): allow
  regexps for methods to be excluded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-02-09 01:28:20 +00:00
parent 031c46f83a
commit bfd1fbf098

View file

@ -843,14 +843,17 @@ module Test
def exclude_from(klass)
excludes = self.excludes
pattern = excludes.keys.grep(Regexp).tap {|k|
break (Regexp.new(k.join('|')) unless k.empty?)
}
klass.class_eval do
public_instance_methods(false).each do |method|
if excludes[method]
if excludes[method] or (pattern and pattern =~ method)
remove_method(method)
end
end
public_instance_methods(true).each do |method|
if excludes[method]
if excludes[method] or (pattern and pattern =~ method)
undef_method(method)
end
end