Skip to content

More features for have_logged_event#10334

Merged
matthinz merged 10 commits intomainfrom
matthinz/have-logged-event-updates
Mar 28, 2024
Merged

More features for have_logged_event#10334
matthinz merged 10 commits intomainfrom
matthinz/have-logged-event-updates

Conversation

@matthinz
Copy link
Contributor

🛠 Summary of changes

This PR:

  • Refactors the have_logged_event RSpec matcher out to a class-based matcher implementing MatcherProtocol rather than using RSpec custom matcher DSL
  • Adds RSpec's built-in CountExpectation to support things like have_logged_event(:foo).thrice
  • Cleans up some of the failure messages that have_logged_event reports

At some point, I'd like to switch have_logged_event over to use .exactly(:once) as the default, but that is not included in this PR (I believe there are a few specs that this would break).

matthinz added 10 commits March 28, 2024 09:54
Provide a general-purpose method for displaying an event mismatch with an attribute diff.
Distinguish strings from symbols
Apparently these class matchers have additional flexibility.
Enables stuff like expect(analytics).to have_logged_event(:whatever).thrice
Try and say 'include()' or 'hash_including()' in failure messages
@matthinz matthinz merged commit e75183f into main Mar 28, 2024
@matthinz matthinz deleted the matthinz/have-logged-event-updates branch March 28, 2024 20:23
@aduth aduth mentioned this pull request Apr 2, 2024
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.

2 participants