Skip to content

Conversation

@giverm
Copy link
Contributor

@giverm giverm commented Nov 12, 2025

Changes

  • Add rubocop-rspec_rails gem and configure in .rubocop.yml
  • Enable RSpecRails cops for HTTP status and validation matchers
  • Update HTTP status codes from :unprocessable_entity to :unprocessable_content
  • Replace numeric status checks (422) with semantic matcher have_http_status
  • Replace be_invalid with not_to be_valid for better RSpec idioms

Preview environment for reporting-app

♻️ Environment destroyed ♻️

@giverm giverm requested review from a team as code owners November 12, 2025 22:07
@giverm giverm requested a review from baonguyenNava November 12, 2025 22:07
@giverm
Copy link
Contributor Author

giverm commented Nov 12, 2025

For this work, I initially set out to add a RuboCop Cop to enforce the use of :unprocessable_content over :unprocessable_entity since the latter is now deprecated. That already existed in the rubocop-rspec_rails plugin, so I figured I would just add that for improved consistency in our specs. Let me know if people are ok with this update.

Copy link
Contributor

@doshitan doshitan left a comment

Choose a reason for hiding this comment

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

Seems fine to me if we only enable the "safe"/default cops and any of the non-default ones we want explicitly. And this can be added to https://github.com/navapbc/template-application-rails.

@giverm giverm force-pushed the giverm/add-rubocop-rspec_rails branch from 4e09d2a to b2d84f0 Compare November 14, 2025 20:58
@giverm
Copy link
Contributor Author

giverm commented Nov 14, 2025

Thanks for the review, @doshitan! I've move part of this work over to the rails template navapbc/template-application-rails#137. I've also updated to disable the RSpecRails/InferredSpecType cop and an explicitly enable a few others rather than keeping NewCops: enable

@giverm giverm changed the title Refactor RSpec tests to follow modern best practices Add rubocop-rspec_rails gem and fix RSpec lint violations Nov 14, 2025
@giverm giverm requested a review from doshitan November 14, 2025 21:07
  - Add rubocop-rspec_rails gem and configure in .rubocop.yml
  - Enable RSpecRails cops for HTTP status and validation matchers
  - Update HTTP status codes from :unprocessable_entity to :unprocessable_content
  - Replace numeric status checks (422) with semantic matcher have_http_status
  - Replace be_invalid with not_to be_valid for better RSpec idioms
@giverm giverm force-pushed the giverm/add-rubocop-rspec_rails branch from 9769f57 to 47293ac Compare November 19, 2025 21:30
@giverm giverm merged commit f8fd228 into main Nov 19, 2025
4 of 5 checks passed
@giverm giverm deleted the giverm/add-rubocop-rspec_rails branch November 19, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants