Overview
Conduct a code reading of RSpec.
Preparation
- Clone the RSpec repository.
Code Reading
- RSpec Invocation
- rspec/rspec-core/blob/main/exe/rspec#L4
- Entry point
- lib/rspec/core/runner.rb#L43
- Calls the class method
invokeof the Runner class - The
disable_autorunmethod disables the auto-run feature
- Calls the class method
- RSpec Execution
- lib/rspec/core/runner.rb#L64
- Calls the class method
runof the Runner - The
trap_interruptmethod handles interruptions like Ctrl+C - If there is a runner in options,
call; otherwise,new.run
- Calls the class method
- lib/rspec/core/runner.rb#L85
- If the test execution ends early, calls the reporting process
- If not ending early, calls the
run_specsmethod
- lib/rspec/core/runner.rb#L113
- Sequentially executes tests, reports results, and returns an exit code