Skip to content

Commit 3177e67

Browse files
committed
Allow coerced tests to be a Regexp.
1 parent f92f02b commit 3177e67

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

test/support/coerceable_test_sqlserver.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ module CoerceableTest
1111

1212
module ClassMethods
1313

14-
def coerce_tests(*methods)
14+
def coerce_tests!(*methods)
1515
methods.each do |method|
1616
self.coerced_tests.push(method)
1717
coerced_test_warning(method)
1818
end
1919
end
2020

21-
def coerce_test!(method)
22-
coerced_test_warning(method)
23-
end
24-
2521
def coerce_all_tests!
2622
once = false
2723
instance_methods(false).each do |method|
@@ -32,14 +28,11 @@ def coerce_all_tests!
3228
STDOUT.puts "Info: Undefined all tests: #{self.name}"
3329
end
3430

35-
def method_added(method)
36-
coerced_test_warning(method) if coerced_tests.include?(method.to_sym)
37-
end
38-
3931
private
4032

4133
def coerced_test_warning(method)
42-
result = undef_method(method) rescue nil
34+
method = instance_methods(false).detect { |m| m =~ method } if method.is_a?(Regexp)
35+
result = undef_method(method) if method && method_defined?(method)
4336
STDOUT.puts "Info: Undefined coerced test: #{self.name}##{method}" unless result.blank?
4437
end
4538

0 commit comments

Comments
 (0)