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
50
51
52
|
# File 'lib/mrubyc/test/generator/attribute.rb', line 10
def run(model_files: [], test_files:)
model_files.each do |model_file|
load model_file
class_name = File.basename(model_file, '.rb').camelize
begin
model_class = Module.const_get(class_name)
rescue NameError => e
print "\e[33m"
puts "[WARN] #{model_file} doesn't have corresponding class `#{class_name}`."
print "\e[m"
end
model_class.class_eval do
def method_missing(_method_name, *_args)
end
end
end
method_locations = {}
description_locations = {}
double_method_locations = {}
MrubycTestCase.init_class_variables
test_files.each do |test_file|
load test_file
test_class = Module.const_get(File.basename(test_file, '.rb').camelize)
method_locations.merge!(test_class.class_variable_get(:@@method_locations))
description_locations.merge!(test_class.class_variable_get(:@@description_locations))
my_test = test_class.new
double_method_locations[test_class] = []
test_class.class_variable_get(:@@added_method_names)[test_class].each do |method_name, _v|
Mrubyc::Test::Generator::Double.init_double_method_locations
begin
my_test.send(method_name)
rescue NoMethodError => e
end
double_method_locations[test_class] << { method_name => Mrubyc::Test::Generator::Double.class_variable_get(:@@double_method_locations) }
end
end
{ method_locations: method_locations,
description_locations: description_locations,
double_method_locations: double_method_locations }
end
|