Method: FeatureMap::Private::TestPyramidFile.write!

Defined in:
lib/feature_map/private/test_pyramid_file.rb

.write!(unit_examples, integration_examples, regression_examples, regression_assignments) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/feature_map/private/test_pyramid_file.rb', line 16

def self.write!(unit_examples, integration_examples, regression_examples, regression_assignments)
  FileUtils.mkdir_p(path.dirname) if !path.dirname.exist?

  regression_file_assignments = regression_assignments['features']&.transform_values do |feature|
    feature['files']&.map { |file| filepath(file) } || []
  end || {}

  content = generate_content(
    unit_examples.group_by { |ex| filepath(ex['id']) },
    integration_examples.group_by { |ex| filepath(ex['id']) },
    regression_examples.group_by { |ex| filepath(ex['id']) },
    regression_file_assignments
  )
  path.write([header_comment, "\n", { FEATURES_KEY => content }.to_yaml].join)
end