| Line | Meaning |
|---|---|
RSpec.configure do |
Opens the RSpec configuration block — all settings go inside this. |
config.expect_with :rspec do |
Configures how expectations (expect) work. |
expectations.include_..._descriptions = true |
Improves custom matcher messages by including chained conditions for clearer failure output. |
config.mock_with :rspec do |
Configures RSpec’s mocking framework. |
mocks.verify_partial_doubles = true |
Ensures mocked/stubbed methods exist on real objects — prevents invalid stubs or typos. |
config.shared_..._behavior = :apply_to_host_groups |
Makes metadata from shared contexts automatically apply to groups using them. |
config.filter_run_when_matching :focus |
Runs only tests marked with :focus — useful for debugging specific examples. |
config....persistence_file_path = "spec/examples.txt" |
Saves test results so RSpec can re-run only failed examples using --only-failures. |
config.disable_monkey_patching! |
Prevents RSpec from adding global methods like describe outside its namespace — keeps Ruby clean. |
if config.files_to_run.one? |
Checks if only one spec file is being executed. |
config.default_formatter = "doc" |
Uses the “documentation” formatter for readable output when running one file. |
# config.profile_examples = 10 |
(Commented) Would show the 10 slowest tests — useful for performance profiling. |
config.order = :random |
Runs specs in random order to reveal hidden dependencies. |
Kernel.srand config.seed |
Seeds Ruby’s random generator so test order can be reproduced. |
end |
Closes the RSpec.configure block. |
Last active
November 4, 2025 22:11
-
-
Save giljr/d21af7f25dc1897a0dd6e320e84e7d2a to your computer and use it in GitHub Desktop.
Expainning all config from rspec_helper.rb file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment