Skip to content

Use hash literal for Mocha .with matcher#982

Merged
tagliala merged 1 commit into
masterfrom
chore/981-mocha-3
Dec 28, 2025
Merged

Use hash literal for Mocha .with matcher#982
tagliala merged 1 commit into
masterfrom
chore/981-mocha-3

Conversation

@tagliala
Copy link
Copy Markdown
Contributor

@tagliala tagliala commented Dec 28, 2025

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).

Close #981

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.93%. Comparing base (3bdc278) to head (48e1d89).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .with matcher calls to use explicit hash literals (e.g., { page: 1 } instead of page: 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.

Comment thread test/url_helpers_test.rb Outdated
Comment thread test/url_helpers_test.rb Outdated
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@tagliala tagliala merged commit bd0a9a2 into master Dec 28, 2025
32 checks passed
@tagliala tagliala deleted the chore/981-mocha-3 branch December 28, 2025 10:56
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.

Mocha 3 breaks CI

2 participants