-
Notifications
You must be signed in to change notification settings - Fork 563
/
Copy pathcoerceable_test_sqlserver.rb
49 lines (40 loc) · 1.23 KB
/
coerceable_test_sqlserver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module ARTest
module SQLServer
module CoerceableTest
extend ActiveSupport::Concern
included do
cattr_accessor :coerced_tests, instance_accessor: false
self.coerced_tests = []
end
module ClassMethods
def coerce_tests!(*methods)
methods.each do |method|
self.coerced_tests.push(method)
coerced_test_warning(method)
end
end
def coerce_all_tests!
once = false
instance_methods(false).each do |method|
next unless method.to_s =~ /\Atest/
undef_method(method)
once = true
end
STDOUT.puts "🙉 🙈 🙊 Undefined all tests: #{self.name}"
end
private
def coerced_test_warning(method)
method = instance_methods(false).select { |m| m =~ method } if method.is_a?(Regexp)
Array(method).each do |m|
result = undef_method(m) if m && method_defined?(m)
if result.blank?
STDOUT.puts "🐳 Unfound coerced test: #{self.name}##{m}"
else
STDOUT.puts "🐵 Undefined coerced test: #{self.name}##{m}"
end
end
end
end
end
end
end