Class: Crystalball::Predictor::ModifiedSpecs

Inherits:
Object
  • Object
show all
Includes:
Strategy
Defined in:
lib/crystalball/predictor/modified_specs.rb

Overview

Used with ‘predictor.use Crystalball::Predictor::ModifiedSpecs.new`. Will find files that match spec regexp and return all new or modified files. You can specify spec regexp using first parameter to `#initialize`.

Instance Method Summary collapse

Methods included from Helpers::PathFormatter

#format_path, #format_paths

Constructor Details

#initialize(spec_pattern = %r{spec/.*_spec\.rb\z}) ⇒ ModifiedSpecs

Returns a new instance of ModifiedSpecs.

Parameters:

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



13
14
15
# File 'lib/crystalball/predictor/modified_specs.rb', line 13

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

Instance Method Details

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

This strategy does not depend on a previously generated example group map. It uses the spec pattern to determine which specs should run.

Parameters:

Returns:

  • (Array<String>)

    the spec paths associated with the changes



22
23
24
25
26
# File 'lib/crystalball/predictor/modified_specs.rb', line 22

def call(diff, _)
  super do
    diff.reject(&:deleted?).map(&:new_relative_path).grep(spec_pattern)
  end
end