14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/polyrun/reporting/rspec_junit.rb', line 14
def install!(json_path: "rspec.json", junit_path: "coverage/junit-coverage.xml", only_if: nil)
pred = only_if || -> { ENV["CI"] }
return unless pred.call
json_abs = File.expand_path(json_path)
FileUtils.mkdir_p(File.dirname(json_abs))
require "rspec/core"
require "rspec/core/formatters/json_formatter"
RSpec.configure do |config|
config.add_formatter RSpec::Core::Formatters::JsonFormatter, json_abs
end
at_exit do
next unless pred.call
FileUtils.mkdir_p(File.dirname(File.expand_path(junit_path)))
if File.file?(json_abs)
Junit.write_from_json_file(json_abs, output_path: junit_path)
end
end
end
|