Module: TestMap::Plugins::RSpec

Defined in:
lib/test_map/plugins/rspec.rb,
lib/test_map/plugins/rspec/cache_formatter.rb

Overview

RSpec integration for TestMap.

Defined Under Namespace

Classes: CacheFormatter

Class Method Summary collapse

Class Method Details

.merge_results(out_file, reporter_results) ⇒ Object

Merge with existing map to preserve mappings for cache-skipped tests



25
26
27
28
29
30
31
# File 'lib/test_map/plugins/rspec.rb', line 25

def self.merge_results(out_file, reporter_results)
  if File.exist?(out_file)
    TestMap.reporter.merge(reporter_results, YAML.safe_load_file(out_file))
  else
    reporter_results
  end
end

.write_resultsObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/test_map/plugins/rspec.rb', line 12

def self.write_results
  out_file = "#{Dir.pwd}/#{Config.config[:out_file]}"
  reporter_results = TestMap.reporter.results

  # All tests were cache-skipped, existing files are still valid
  return if reporter_results.empty?

  full_results = merge_results(out_file, reporter_results)
  File.write(out_file, full_results.to_yaml)
  TestMap.cache.write(full_results) if TestMap.suite_passed
end