Module: RSpec::Covers
- Defined in:
- lib/rspec/covers.rb,
lib/rspec/covers/version.rb,
lib/rspec/covers/reporter.rb,
lib/rspec/covers/formatter.rb,
lib/rspec/covers/rake_task.rb,
lib/rspec/covers/tracer/nc.rb,
lib/rspec/covers/evaluation.rb,
lib/rspec/covers/tracer/ncc.rb,
lib/rspec/covers/declaration.rb,
lib/rspec/covers/integration.rb,
lib/rspec/covers/tracer/lcba.rb,
lib/rspec/covers/method_entry.rb,
lib/rspec/covers/method_label.rb,
lib/rspec/covers/source_range.rb,
lib/rspec/covers/code_location.rb,
lib/rspec/covers/configuration.rb,
lib/rspec/covers/strict_verdict.rb,
lib/rspec/covers/tracer/dynamic.rb,
lib/rspec/covers/metadata_reader.rb,
lib/rspec/covers/checked_coverage.rb,
lib/rspec/covers/tracer/composite.rb,
lib/rspec/covers/tracer/tokenizer.rb,
lib/rspec/covers/tracer/suggestion.rb,
lib/rspec/covers/probe/call_log_probe.rb,
lib/rspec/covers/probe/coverage_probe.rb,
lib/rspec/covers/production_inventory.rb,
lib/rspec/covers/static_method_scanner.rb,
lib/rspec/covers/tracer/dynamic_corpus.rb,
lib/rspec/covers/declaration_validation.rb,
sig/rspec/covers.rbs
Defined Under Namespace
Modules: ExpectHook, Integration, MetadataReader, MethodLabel, Probe, SourceRange, Tracer Classes: CheckedCoverage, CodeLocation, CodeRegion, Configuration, Declaration, DeclarationValidation, DeclarationValidator, Error, Evaluation, ExampleResult, Formatter, MethodEntry, ProductionInventory, RakeTask, Reporter, StaticMethodScanner, StrictCoverageError, StrictVerdict
Constant Summary collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
Class Method Summary collapse
- .call_log_probe ⇒ Object
- .configure(rspec_config = nil) {|configuration| ... } ⇒ Configuration
- .coverage_probe ⇒ Object
- .dynamic_corpus ⇒ Object
- .install!(rspec_config) ⇒ void
- .installed? ⇒ Boolean
- .mark_installed! ⇒ Object
- .process_example(example, executed_locations, call_log) ⇒ Object
- .record_expectation_actual(actual) ⇒ Object
- .reset! ⇒ Object
- .run_example(example) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
14 15 16 |
# File 'lib/rspec/covers.rb', line 14 def configuration @configuration ||= Configuration.new end |
Class Method Details
.call_log_probe ⇒ Object
45 46 47 |
# File 'lib/rspec/covers.rb', line 45 def call_log_probe @call_log_probe ||= Probe::CallLogProbe.new(configuration) end |
.configure(rspec_config = nil) {|configuration| ... } ⇒ Configuration
18 19 20 21 22 23 |
# File 'lib/rspec/covers.rb', line 18 def configure(rspec_config = nil) yield configuration if block_given? Integration.install!(rspec_config) if rspec_config configuration end |
.coverage_probe ⇒ Object
41 42 43 |
# File 'lib/rspec/covers.rb', line 41 def coverage_probe @coverage_probe ||= Probe::CoverageProbe.new(configuration) end |
.dynamic_corpus ⇒ Object
49 50 51 |
# File 'lib/rspec/covers.rb', line 49 def dynamic_corpus @dynamic_corpus ||= Tracer::DynamicCorpus.new end |
.install!(rspec_config) ⇒ void
This method returns an undefined value.
25 26 27 |
# File 'lib/rspec/covers.rb', line 25 def install!(rspec_config) Integration.install!(rspec_config) end |
.installed? ⇒ Boolean
29 30 31 |
# File 'lib/rspec/covers.rb', line 29 def installed? @installed == true end |
.mark_installed! ⇒ Object
33 34 35 |
# File 'lib/rspec/covers.rb', line 33 def mark_installed! @installed = true end |
.process_example(example, executed_locations, call_log) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rspec/covers.rb', line 72 def process_example(example, executed_locations, call_log) declaration = Declaration.from_example(example, configuration) dynamic_corpus.record(example.id, call_log.labels) if configuration.suggest || configuration.validate_declarations measured_locations = measured_locations(executed_locations, declaration, call_log) verdict = StrictVerdict.call( executed_locations: measured_locations, declaration: declaration, config: configuration ) example.[:rspec_covers_risky] = verdict.risky? suggestions = suggestions_for(example, declaration, call_log, executed_locations) validation = validation_for(example, declaration, call_log, executed_locations) unchecked_locations = unchecked_locations_for(executed_locations, measured_locations) reporter.record( ExampleResult.new( id: example.id, file: example.[:file_path], line: example.[:line_number], description: example.full_description, verdict: verdict, suggestions: suggestions, declaration_validation: validation, declaration: declaration, example: example, call_log: call_log, executed_locations: executed_locations, measured_locations: measured_locations, unchecked_locations: unchecked_locations ) ) emit_warning(example, verdict, suggestions, validation) raise StrictCoverageError, verdict if fail_risky?(verdict, example) end |
.record_expectation_actual(actual) ⇒ Object
66 67 68 69 70 |
# File 'lib/rspec/covers.rb', line 66 def record_expectation_actual(actual) ids = Thread.current[:rspec_covers_expectation_object_ids] ids << actual.__id__ if ids call_log_probe.record_expectation(actual) if call_log_enabled? end |
.reset! ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/rspec/covers.rb', line 108 def reset! @configuration = Configuration.new @reporter = Reporter.new @coverage_probe = nil @call_log_probe = nil @dynamic_corpus = nil @installed = false end |
.run_example(example) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rspec/covers.rb', line 53 def run_example(example) Thread.current[:rspec_covers_expectation_object_ids] = [] before_snapshot = coverage_probe.snapshot call_log_probe.start_example if call_log_enabled? example.run ensure call_log = call_log_enabled? ? call_log_probe.stop_example : Probe::CallLog.new(calls: [], returns_by_object_id: {}) executed = coverage_probe.difference(before_snapshot || {}, coverage_probe.snapshot) process_example(example, executed, call_log) if example Thread.current[:rspec_covers_expectation_object_ids] = nil end |