Class: Crystalball::RSpec::Runner
- Inherits:
-
RSpec::Core::Runner
- Object
- RSpec::Core::Runner
- Crystalball::RSpec::Runner
- Includes:
- PredictionPruning
- Defined in:
- lib/crystalball/rspec/runner.rb,
lib/crystalball/rspec/runner/configuration.rb
Overview
Our custom RSpec runner to run predictions
Defined Under Namespace
Classes: Configuration
Class Attribute Summary collapse
- .config ⇒ Object readonly
- .prediction_builder ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#configure(err, out) ⇒ Object
Backward compatibility for RSpec < 3.7.
- #setup(err, out) ⇒ Object
Methods included from PredictionPruning
Class Attribute Details
.config ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/crystalball/rspec/runner.rb', line 40 def config @config ||= begin config_src = if config_file require 'yaml' YAML.safe_load(config_file.read) else {} end Configuration.new(config_src) end end |
.prediction_builder ⇒ Object
36 37 38 |
# File 'lib/crystalball/rspec/runner.rb', line 36 def prediction_builder @prediction_builder ||= config['prediction_builder_class'].new(config) end |
Class Method Details
.prepare ⇒ Object
32 33 34 |
# File 'lib/crystalball/rspec/runner.rb', line 32 def prepare config['runner_class'].load_execution_map end |
.reset! ⇒ Object
27 28 29 30 |
# File 'lib/crystalball/rspec/runner.rb', line 27 def reset! self.prediction_builder = nil self.config = nil end |
.run(args, err = $stderr, out = $stdout) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/crystalball/rspec/runner.rb', line 15 def run(args, err = $stderr, out = $stdout) return config['runner_class'].run(args, err, out) unless config['runner_class'] == self Crystalball.log :info, "Crystalball starts to glow..." prediction = build_prediction Crystalball.log :debug, "Prediction: #{prediction.first(5).join(' ')}#{'...' if prediction.size > 5}" Crystalball.log :info, "Starting RSpec." super(args + prediction, err, out) end |
Instance Method Details
#configure(err, out) ⇒ Object
Backward compatibility for RSpec < 3.7
98 99 100 101 102 |
# File 'lib/crystalball/rspec/runner.rb', line 98 def configure(err, out) @configuration.error_stream = err @configuration.output_stream = out if @configuration.output_stream == $stdout @options.configure(@configuration) end |
#setup(err, out) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/crystalball/rspec/runner.rb', line 80 def setup(err, out) configure(err, out) @configuration.load_spec_files Filtering.remove_unnecessary_filters(@configuration, @options.[:files_or_directories_to_run]) if reconfiguration_needed? Crystalball.log :warn, "Prediction examples size #{@world.example_count} is over the limit (#{examples_limit})" Crystalball.log :warn, "Prediction is pruned to fit the limit!" reconfigure_to_limit @configuration.load_spec_files end @world.announce_filters end |