Use hash literal for Mocha .with matcher#982
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #982 +/- ##
=======================================
Coverage 98.93% 98.93%
=======================================
Files 14 14
Lines 563 563
=======================================
Hits 557 557
Misses 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ae9ec0b to
20ac96a
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates test mocks to be compatible with Mocha 3.0, which changed argument matching behavior for the .with matcher. The matcher now requires explicit hash literals instead of keyword arguments, ensuring type-exact matching.
- Updated all
.withmatcher calls to use explicit hash literals (e.g.,{ page: 1 }instead ofpage: 1) - Removed version constraint on mocha gem dependency across all Rails version-specific Gemfiles
- Updated Gemfile.lock files to reflect mocha version 3.0.1
Reviewed changes
Copilot reviewed 7 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/url_helpers_test.rb | Updated .with matchers to use hash literals for options parameters in URL helper tests |
| test/strong_parameters_test.rb | Updated .with matchers to use hash literals for permitted parameters in strong parameters tests |
| gemfiles/rails_80/Gemfile | Removed mocha version constraint, allowing upgrade to 3.0+ |
| gemfiles/rails_80/Gemfile.lock | Updated mocha version from 2.8.2 to 3.0.1 |
| gemfiles/rails_72/Gemfile | Removed mocha version constraint, allowing upgrade to 3.0+ |
| gemfiles/rails_72/Gemfile.lock | Updated mocha version from 2.8.2 to 3.0.1 |
| gemfiles/rails_71/Gemfile | Removed mocha version constraint, allowing upgrade to 3.0+ |
| gemfiles/rails_71/Gemfile.lock | Updated mocha version from 2.8.2 to 3.0.1 |
| gemfiles/rails_70/Gemfile | Removed mocha version constraint, allowing upgrade to 3.0+ |
| gemfiles/rails_70/Gemfile.lock | Updated mocha version from 2.8.2 to 3.0.1 |
| Gemfile | Removed mocha version constraint, allowing upgrade to 3.0+ |
| Gemfile.lock | Updated mocha version from 2.8.2 to 3.0.1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Mocha commit freerange/mocha@38553330 changed argument matching behavior: `.with` no longer normalizes or coerces hash options. The `.with` matcher now requires that arguments match exactly, including type. This means a hash must be an explicit hash literal, not just keyword arguments. Update tests to pass options as a hash literal, e.g. `with({ permitted: param })` instead of `with(permitted: param)`. Additionally, add missing `.once` calls for consistency, as highlighted by Copilot during the automated review. Close #981
20ac96a to
48e1d89
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Mocha commit freerange/mocha@38553330 changed argument matching
behavior:
.withno longer normalizes or coerces hash options.The
.withmatcher now requires that arguments match exactly,including type. This means a hash must be an explicit hash
literal, not just keyword arguments.
Update tests to pass options as a hash literal, e.g.
with({ permitted: param })instead ofwith(permitted: param).Close #981