Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local-friendly RSpec setup #5989

Merged
merged 3 commits into from
Aug 21, 2024
Merged

Conversation

thejonroberts
Copy link
Contributor

What github issue is this PR for, if any?

No Issue, concerns local development only.

What changed, and why?

Prior to change, running bin/rspec locally would produce following error in my (mac) environment:

lib/ruby/gems/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:105:in `block in preload': Spring reloads, and therefore needs the application to have reloading enabled.
Please, set config.cache_classes to false in config/environments/test.rb.

(Note I did not do what the above error says to do, that was the 'old' way to do it before Rails 7.1, I guess rspec hasn't updated the error?)

So, the only way to run a specific spec or file was to use focus tag (fit, fdescribe, etc...) while running bin/rails spec, which runs javascript/css builds each run - annoying if running backed / not changing javascript/css. The focus tag could also be forgotten about and committed.

This change allows copy/pasting lines from failure notifications, for example, bin/rspec path/to/file.rb:23. Used ENV["CI"] so that CI test run speed is not affected.

Also made a change that filters gems from backtrace of spec failures, which aren't very useful. Typically, I only want to see trace of files we have control over. This can be overridden by passing option to rspec bin/rspec --backtrace. I added a comment to that effect.

Allows running bin/rspec for developers, should not affect CI.
Can be overridden with `--backtrace` option.
@github-actions github-actions bot added the ruby Pull requests that update Ruby code label Aug 14, 2024
Copy link
Collaborator

@elasticspoon elasticspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't use bin/rspec but it did not work before this fix and it works now 👍

config/environments/test.rb Outdated Show resolved Hide resolved
Co-authored-by: Yuri Bocharov <[email protected]>
@elasticspoon elasticspoon merged commit 41bfcc9 into rubyforgood:main Aug 21, 2024
17 checks passed
@thejonroberts thejonroberts deleted the rspec-local branch August 22, 2024 18:19
@thejonroberts thejonroberts mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants