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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/inline_tests.rb', line 7
def self.run!
test_passes = 0
test_fails = 0
begin
Rails.application.eager_load!
rescue
end
puts "Starting inline test suite:"
all_tests_start_time = Time.now
METHODS_WITH_INLINE_TESTS.each do |method|
method_signature = if method.receiver.class.name === Object.name
"#{method.receiver}::#{method.name}"
elsif method.receiver.class.name == Class.name
"#{method.receiver.name}::self.#{method.name}"
else
"#{method.receiver.class.name}::#{method.name}"
end
start_time = Time.now
begin
method.run_inline_tests test_time = Time.now - start_time
test_passes += 1
puts " #{method_signature} - PASSED (#{format_tiny_time test_time} seconds)"
rescue InlineTestFailure => failure_information
test_time = Time.now - start_time
errors = failure_information
test_fails += 1
puts " #{method_signature} - FAILED (#{format_tiny_time test_time} seconds)"
puts errors
end
end
all_tests_end_time = Time.now
puts "#{METHODS_WITH_INLINE_TESTS.count} inline tests ran in #{format_tiny_time all_tests_end_time - all_tests_start_time} seconds."
puts " #{test_passes} PASSED"
puts " #{test_fails} FAILS"
puts
puts "#{METHODS_THAT_NEED_TESTS.count} methods still need tests:"
METHODS_THAT_NEED_TESTS.each do |method|
puts " #{method.receiver.name}##{method.original_name}"
puts " #{method.source_location.join(':')}"
end
nil
end
|