thoughtbot / shoulda-matchers

Simple one-liner tests for common Rails functionality
https://matchers.shoulda.io
MIT License
3.5k stars 911 forks source link

feat: Add `default` qualifier to `define_enum_for` matcher #1627

Closed matsales28 closed 4 months ago

matsales28 commented 4 months ago

On this commit we're adding a new qualifier to the define_enum_for matcher called with_default. This qualifier is used to test that the enum is defined with a default value. A proc can also be passed, and will be called once each time a new value is needed.

It's nice to note that using Time or Date as the return of Procs as default value can lead to flaky tests, so it's recommended to freeze time or date to avoid this.