Class: Crystalball::Predictor::AssociatedSpecs
- Inherits:
-
Object
- Object
- Crystalball::Predictor::AssociatedSpecs
- Includes:
- Strategy
- Defined in:
- lib/crystalball/predictor/associated_specs.rb
Overview
Used with ‘predictor.use Crystalball::Predictor::AssociatedSpecs.new(from: %rmodels/(models/(.*)models/(.*).rb, to: “./spec/models/%s_spec.rb”)`. When used will look for files matched to `from` regex and use captures to fill `to` string to get paths of proper specs
Instance Method Summary collapse
-
#call(diff, _map) ⇒ Array<String>
This strategy does not depend on a previously generated example group map.
-
#initialize(from:, to:) ⇒ AssociatedSpecs
constructor
A new instance of AssociatedSpecs.
Methods included from Helpers::PathFormatter
Constructor Details
#initialize(from:, to:) ⇒ AssociatedSpecs
Returns a new instance of AssociatedSpecs.
15 16 17 18 |
# File 'lib/crystalball/predictor/associated_specs.rb', line 15 def initialize(from:, to:) @from = from @to = to end |
Instance Method Details
#call(diff, _map) ⇒ Array<String>
This strategy does not depend on a previously generated example group map. It uses the defined regex rules to infer which specs to run.
25 26 27 28 29 |
# File 'lib/crystalball/predictor/associated_specs.rb', line 25 def call(diff, _map) super do diff.map(&:relative_path).grep(from).map { |source_file_path| to % captures(source_file_path) } end end |