Module: RspecSprint::Doctor
- Defined in:
- lib/rspec_sprint/doctor.rb
Overview
Turns a Collector::Result into a human report, handling the degraded paths (design D4 / D10④): distinguish “the suite never produced readable output” (diagnosis impossible) from “the suite ran but had failures” (still diagnosable, with a warning), and from “test-prof wasn’t active” (skip Rule① with a one-line setup hint).
Class Method Summary collapse
- .diagnose(result) ⇒ Object
- .diagnosis_impossible(result) ⇒ Object
- .factory_prof_missing_hint ⇒ Object
- .suite_red_warning(result) ⇒ Object
Class Method Details
.diagnose(result) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rspec_sprint/doctor.rb', line 14 def diagnose(result) return diagnosis_impossible(result) unless result.rspec_json? sections = [] sections << suite_red_warning(result) if result.suite_red? sections << factory_prof_missing_hint unless result.factory_prof? sections << Diagnosis.from_files( rspec_json: result.rspec_json_path, factory_prof_json: result.factory_prof? ? result.factory_prof_path : nil ) sections.join("\n\n") end |
.diagnosis_impossible(result) ⇒ Object
27 28 29 30 |
# File 'lib/rspec_sprint/doctor.rb', line 27 def diagnosis_impossible(result) "診断不可: rspec の出力(JSON)が読めませんでした(exit #{result.exit_status})。" \ "suite はブートしましたか? `bundle exec rspec` を直接実行してエラーを確認してください。" end |
.factory_prof_missing_hint ⇒ Object
37 38 39 40 41 |
# File 'lib/rspec_sprint/doctor.rb', line 37 def factory_prof_missing_hint "注意: FactoryProf の出力がありません(test-prof 未導入、または spec_helper で require 忘れ)。" \ "factory 関連の診断(Rule①)をスキップしました。\n" \ '設定: Gemfile の development/test グループに test-prof を追加し、spec_helper で `require "test_prof"` してください。' end |
.suite_red_warning(result) ⇒ Object
32 33 34 35 |
# File 'lib/rspec_sprint/doctor.rb', line 32 def suite_red_warning(result) "注意: suite に失敗があります(exit #{result.exit_status})。" \ "全 example が走り切っていない場合、以下の数値は不安定なことがあります。" end |