Class: MissCleo::TestConfigurations::CucumberConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/miss_cleo/test_configurations/cucumber_config.rb

Constant Summary collapse

CUCUMBER_MAP =
"cucumber_map.json"
LOGS =
[]

Class Method Summary collapse

Class Method Details

.setup_hooks(context) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/miss_cleo/test_configurations/cucumber_config.rb', line 7

def self.setup_hooks(context)
  if ENV["COVERAGE"]
    Coverage.start
    context.Around do |scenario, execute|
      MissCleo::TemplateHelper.reset_coverage
      before = Coverage.peek_result
      execute.call
      after = Coverage.peek_result
      templates = MissCleo::TemplateHelper.template_coverage.uniq
      if file_and_line = scenario.try(:file_colon_line)
        LOGS << [ file_and_line, { before: CoverageFilter.filter_and_trim(before), after: CoverageFilter.filter_and_trim(after), templates: templates } ]
      end
    end

    at_exit do
      File.open(CUCUMBER_MAP, 'w') { |f| f.write JSON.dump LOGS }
    end
  end
end