Class: Crystalball::Predictor::ModifiedSupportSpecs

Inherits:
Object
  • Object
show all
Includes:
Helpers::AffectedExampleGroupsDetector, Strategy
Defined in:
lib/crystalball/predictor/modified_support_specs.rb

Overview

Used with ‘predictor.use Crystalball::Predictor::ModifiedSupportSpecs.new`. Will find files that match passed regexp and return full spec files which uses matched support spec files. Perfectly works for shared_context and shared_examples.

Instance Method Summary collapse

Methods included from Helpers::AffectedExampleGroupsDetector

#detect_examples

Methods included from Helpers::PathFormatter

#format_path, #format_paths

Constructor Details

#initialize(support_spec_pattern = %r{spec/support/.*\.rb\z}) ⇒ ModifiedSupportSpecs

Returns a new instance of ModifiedSupportSpecs.

Parameters:

  • support_spec_pattern (Regexp) (defaults to: %r{spec/support/.*\.rb\z})
    • regexp to filter support specs files



15
16
17
# File 'lib/crystalball/predictor/modified_support_specs.rb', line 15

def initialize(support_spec_pattern = %r{spec/support/.*\.rb\z})
  @support_spec_pattern = support_spec_pattern
end

Instance Method Details

#call(diff, map) ⇒ Array<String>

Returns the spec paths associated with the changes.

Parameters:

Returns:

  • (Array<String>)

    the spec paths associated with the changes



24
25
26
27
28
29
30
31
32
# File 'lib/crystalball/predictor/modified_support_specs.rb', line 24

def call(diff, map)
  super do
    changed_support_files = diff.map(&:relative_path).grep(support_spec_pattern)

    examples = detect_examples(changed_support_files, map)

    examples.map { |e| e.to_s.split('[').first }.uniq
  end
end