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
|
# File 'lib/workarea/testing/decoration_reporter.rb', line 3
def format_rerun_snippet(result)
location, line = result.method(result.name).source_location
return super unless location.ends_with?(Rails::Decorators.extension.to_s)
relative_path = location.split('/test/').last
possible_original_tests = workarea_roots
.map { |r| r.join('test', relative_path).to_s }
.map { |p| p.gsub(/\.#{Rails::Decorators.extension}$/, '.rb') }
original_test = possible_original_tests.detect { |f| File.exist?(f) }
if original_test.blank?
raise <<~MSG
Problem:
Can't find original test #{original_test} for decorator #{location}
Summary:
Test decorators need to have the same path as the original test.
Resolution:
Check that your test decoration has the right path and file name.
MSG
end
"From decorator: #{location}:#{line}\n#{self.executable} #{original_test}"
end
|