7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/miss_cleo/test_configurations/rspec_config.rb', line 7
def self.setup_hooks(context)
if ENV["COVERAGE"]
Coverage.start
RSpec.configuration.after(:suite) do
File.open(RSPEC_MAP, 'w') { |f| f.write JSON.dump LOGS }
end
RSpec.configuration.around(:example) do |example|
MissCleo::TemplateHelper.reset_coverage
before = Coverage.peek_result
example.call
after = Coverage.peek_result
templates = MissCleo::TemplateHelper.template_coverage.uniq
LOGS << [ example.location, {
before: CoverageFilter.filter_and_trim(before),
after: CoverageFilter.filter_and_trim(after),
templates: templates
} ]
end
end
end
|