Class: RSpecTracer::Reporter
- Inherits:
-
Object
- Object
- RSpecTracer::Reporter
- Defined in:
- lib/rspec_tracer/reporter.rb
Instance Attribute Summary collapse
-
#all_examples ⇒ Object
readonly
Returns the value of attribute all_examples.
-
#all_files ⇒ Object
readonly
Returns the value of attribute all_files.
-
#deleted_files ⇒ Object
readonly
Returns the value of attribute deleted_files.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#duplicate_examples ⇒ Object
readonly
Returns the value of attribute duplicate_examples.
-
#examples_coverage ⇒ Object
readonly
Returns the value of attribute examples_coverage.
-
#failed_examples ⇒ Object
readonly
Returns the value of attribute failed_examples.
-
#flaky_examples ⇒ Object
readonly
Returns the value of attribute flaky_examples.
-
#interrupted_examples ⇒ Object
readonly
Returns the value of attribute interrupted_examples.
-
#last_run ⇒ Object
Returns the value of attribute last_run.
-
#modified_files ⇒ Object
readonly
Returns the value of attribute modified_files.
-
#pending_examples ⇒ Object
readonly
Returns the value of attribute pending_examples.
-
#possibly_flaky_examples ⇒ Object
readonly
Returns the value of attribute possibly_flaky_examples.
-
#reverse_dependency ⇒ Object
Returns the value of attribute reverse_dependency.
-
#skipped_examples ⇒ Object
readonly
Returns the value of attribute skipped_examples.
Instance Method Summary collapse
- #deregister_duplicate_examples ⇒ Object
- #duplicate_example?(example_id) ⇒ Boolean
- #example_deleted?(example_id) ⇒ Boolean
- #example_failed?(example_id) ⇒ Boolean
- #example_interrupted?(example_id) ⇒ Boolean
- #example_passed?(example_id) ⇒ Boolean
- #example_pending?(example_id) ⇒ Boolean
- #example_skipped?(example_id) ⇒ Boolean
- #file_changed?(file_name) ⇒ Boolean
- #file_deleted?(file_name) ⇒ Boolean
- #file_modified?(file_name) ⇒ Boolean
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #on_example_failed(example_id, result) ⇒ Object
- #on_example_passed(example_id, result) ⇒ Object
- #on_example_pending(example_id, result) ⇒ Object
- #on_example_skipped(example_id) ⇒ Object
- #on_file_deleted(file_name) ⇒ Object
- #on_file_modified(file_name) ⇒ Object
- #register_deleted_examples(seen_examples) ⇒ Object
- #register_dependency(example_id, file_name) ⇒ Object
- #register_example(example) ⇒ Object
- #register_examples_coverage(examples_coverage) ⇒ Object
- #register_failed_example(example_id) ⇒ Object
- #register_flaky_example(example_id) ⇒ Object
- #register_interrupted_examples ⇒ Object
- #register_pending_example(example_id) ⇒ Object
- #register_possibly_flaky_example(example_id) ⇒ Object
- #register_source_file(source_file) ⇒ Object
Constructor Details
#initialize ⇒ Reporter
Returns a new instance of Reporter.
12 13 14 15 16 17 |
# File 'lib/rspec_tracer/reporter.rb', line 12 def initialize initialize_examples initialize_files initialize_dependency initialize_coverage end |
Instance Attribute Details
#all_examples ⇒ Object (readonly)
Returns the value of attribute all_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def all_examples @all_examples end |
#all_files ⇒ Object (readonly)
Returns the value of attribute all_files.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def all_files @all_files end |
#deleted_files ⇒ Object (readonly)
Returns the value of attribute deleted_files.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def deleted_files @deleted_files end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def dependency @dependency end |
#duplicate_examples ⇒ Object (readonly)
Returns the value of attribute duplicate_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def duplicate_examples @duplicate_examples end |
#examples_coverage ⇒ Object (readonly)
Returns the value of attribute examples_coverage.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def examples_coverage @examples_coverage end |
#failed_examples ⇒ Object (readonly)
Returns the value of attribute failed_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def failed_examples @failed_examples end |
#flaky_examples ⇒ Object (readonly)
Returns the value of attribute flaky_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def flaky_examples @flaky_examples end |
#interrupted_examples ⇒ Object (readonly)
Returns the value of attribute interrupted_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def interrupted_examples @interrupted_examples end |
#last_run ⇒ Object
Returns the value of attribute last_run.
10 11 12 |
# File 'lib/rspec_tracer/reporter.rb', line 10 def last_run @last_run end |
#modified_files ⇒ Object (readonly)
Returns the value of attribute modified_files.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def modified_files @modified_files end |
#pending_examples ⇒ Object (readonly)
Returns the value of attribute pending_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def pending_examples @pending_examples end |
#possibly_flaky_examples ⇒ Object (readonly)
Returns the value of attribute possibly_flaky_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def possibly_flaky_examples @possibly_flaky_examples end |
#reverse_dependency ⇒ Object
Returns the value of attribute reverse_dependency.
10 11 12 |
# File 'lib/rspec_tracer/reporter.rb', line 10 def reverse_dependency @reverse_dependency end |
#skipped_examples ⇒ Object (readonly)
Returns the value of attribute skipped_examples.
5 6 7 |
# File 'lib/rspec_tracer/reporter.rb', line 5 def skipped_examples @skipped_examples end |
Instance Method Details
#deregister_duplicate_examples ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rspec_tracer/reporter.rb', line 24 def deregister_duplicate_examples @duplicate_examples.select! { |_, examples| examples.count > 1 } return if @duplicate_examples.empty? @all_examples.reject! { |example_id, _| @duplicate_examples.key?(example_id) } end |
#duplicate_example?(example_id) ⇒ Boolean
96 97 98 |
# File 'lib/rspec_tracer/reporter.rb', line 96 def duplicate_example?(example_id) @duplicate_examples.key?(example_id) end |
#example_deleted?(example_id) ⇒ Boolean
120 121 122 |
# File 'lib/rspec_tracer/reporter.rb', line 120 def example_deleted?(example_id) @deleted_examples.include?(example_id) end |
#example_failed?(example_id) ⇒ Boolean
112 113 114 |
# File 'lib/rspec_tracer/reporter.rb', line 112 def example_failed?(example_id) @failed_examples.include?(example_id) end |
#example_interrupted?(example_id) ⇒ Boolean
100 101 102 |
# File 'lib/rspec_tracer/reporter.rb', line 100 def example_interrupted?(example_id) @interrupted_examples.include?(example_id) end |
#example_passed?(example_id) ⇒ Boolean
104 105 106 |
# File 'lib/rspec_tracer/reporter.rb', line 104 def example_passed?(example_id) @passed_examples.include?(example_id) end |
#example_pending?(example_id) ⇒ Boolean
116 117 118 |
# File 'lib/rspec_tracer/reporter.rb', line 116 def example_pending?(example_id) @pending_examples.include?(example_id) end |
#example_skipped?(example_id) ⇒ Boolean
108 109 110 |
# File 'lib/rspec_tracer/reporter.rb', line 108 def example_skipped?(example_id) @skipped_examples.include?(example_id) end |
#file_changed?(file_name) ⇒ Boolean
144 145 146 |
# File 'lib/rspec_tracer/reporter.rb', line 144 def file_changed?(file_name) file_deleted?(file_name) || file_modified?(file_name) end |
#file_deleted?(file_name) ⇒ Boolean
136 137 138 |
# File 'lib/rspec_tracer/reporter.rb', line 136 def file_deleted?(file_name) @deleted_files.include?(file_name) end |
#file_modified?(file_name) ⇒ Boolean
140 141 142 |
# File 'lib/rspec_tracer/reporter.rb', line 140 def file_modified?(file_name) @modified_files.include?(file_name) end |
#on_example_failed(example_id, result) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rspec_tracer/reporter.rb', line 43 def on_example_failed(example_id, result) return if @duplicate_examples.key?(example_id) @failed_examples << example_id @all_examples[example_id][:execution_result] = formatted_execution_result(result) end |
#on_example_passed(example_id, result) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rspec_tracer/reporter.rb', line 36 def on_example_passed(example_id, result) return if @duplicate_examples.key?(example_id) @passed_examples << example_id @all_examples[example_id][:execution_result] = formatted_execution_result(result) end |
#on_example_pending(example_id, result) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rspec_tracer/reporter.rb', line 50 def on_example_pending(example_id, result) return if @duplicate_examples.key?(example_id) @pending_examples << example_id @all_examples[example_id][:execution_result] = formatted_execution_result(result) end |
#on_example_skipped(example_id) ⇒ Object
32 33 34 |
# File 'lib/rspec_tracer/reporter.rb', line 32 def on_example_skipped(example_id) @skipped_examples << example_id end |
#on_file_deleted(file_name) ⇒ Object
128 129 130 |
# File 'lib/rspec_tracer/reporter.rb', line 128 def on_file_deleted(file_name) @deleted_files << file_name end |
#on_file_modified(file_name) ⇒ Object
132 133 134 |
# File 'lib/rspec_tracer/reporter.rb', line 132 def on_file_modified(file_name) @modified_files << file_name end |
#register_deleted_examples(seen_examples) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rspec_tracer/reporter.rb', line 69 def register_deleted_examples(seen_examples) @deleted_examples = seen_examples.keys.to_set - (@skipped_examples | @all_examples.keys) @deleted_examples -= @interrupted_examples @deleted_examples.select! do |example_id| example = seen_examples[example_id] file_changed?(example[:file_name]) || file_changed?(example[:rerun_file_name]) end end |
#register_dependency(example_id, file_name) ⇒ Object
148 149 150 |
# File 'lib/rspec_tracer/reporter.rb', line 148 def register_dependency(example_id, file_name) @dependency[example_id] << file_name end |
#register_example(example) ⇒ Object
19 20 21 22 |
# File 'lib/rspec_tracer/reporter.rb', line 19 def register_example(example) @all_examples[example[:example_id]] = example @duplicate_examples[example[:example_id]] << example end |
#register_examples_coverage(examples_coverage) ⇒ Object
152 153 154 |
# File 'lib/rspec_tracer/reporter.rb', line 152 def register_examples_coverage(examples_coverage) @examples_coverage = examples_coverage end |
#register_failed_example(example_id) ⇒ Object
88 89 90 |
# File 'lib/rspec_tracer/reporter.rb', line 88 def register_failed_example(example_id) @failed_examples << example_id end |
#register_flaky_example(example_id) ⇒ Object
84 85 86 |
# File 'lib/rspec_tracer/reporter.rb', line 84 def register_flaky_example(example_id) @flaky_examples << example_id end |
#register_interrupted_examples ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspec_tracer/reporter.rb', line 57 def register_interrupted_examples @all_examples.each_pair do |example_id, example| next if example.key?(:execution_result) @interrupted_examples << example_id end return if @interrupted_examples.empty? puts "RSpec tracer is not processing #{@interrupted_examples.count} interrupted examples" end |
#register_pending_example(example_id) ⇒ Object
92 93 94 |
# File 'lib/rspec_tracer/reporter.rb', line 92 def register_pending_example(example_id) @pending_examples << example_id end |
#register_possibly_flaky_example(example_id) ⇒ Object
80 81 82 |
# File 'lib/rspec_tracer/reporter.rb', line 80 def register_possibly_flaky_example(example_id) @possibly_flaky_examples << example_id end |
#register_source_file(source_file) ⇒ Object
124 125 126 |
# File 'lib/rspec_tracer/reporter.rb', line 124 def register_source_file(source_file) @all_files[source_file[:file_name]] = source_file end |