DEV Community

Cover image for RSpec Code Reading
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

RSpec Code Reading

This article was originally published on bmf-tech.com.

Overview

Conduct a code reading of RSpec.

Preparation

  1. Clone the RSpec repository.
  2. https://github.com/rspec/rspec-core

Code Reading

  1. RSpec Invocation
  2. rspec/rspec-core/blob/main/exe/rspec#L4
    • Entry point
  3. lib/rspec/core/runner.rb#L43
    • Calls the class method invoke of the Runner class
    • The disable_autorun method disables the auto-run feature
  4. RSpec Execution
  5. lib/rspec/core/runner.rb#L64
    • Calls the class method run of the Runner
    • The trap_interrupt method handles interruptions like Ctrl+C
    • If there is a runner in options, call; otherwise, new.run
  6. lib/rspec/core/runner.rb#L85
    • If the test execution ends early, calls the reporting process
    • If not ending early, calls the run_specs method
  7. lib/rspec/core/runner.rb#L113
    • Sequentially executes tests, reports results, and returns an exit code

Top comments (0)