Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Compatibility issue with shoulda-matcher 5.2.0 #56

Open
dubsdaazn opened this issue Nov 7, 2022 · 0 comments
Open

Compatibility issue with shoulda-matcher 5.2.0 #56

dubsdaazn opened this issue Nov 7, 2022 · 0 comments

Comments

@dubsdaazn
Copy link

It appears the latest version of shoulda-matchers 5.2.0 change the way they implemented #define_enum_for with #with_values causing specs to fail.

in the model (task)

  enum status: {
    validating: 0, review: 1, processing: 2, completed: 3, completed_with_errors: 4, failed: 5, cancelled: 6
  } do
     # event block...
  end

in the spec

    it 'defines all required states' do
      expect(task).to define_enum_for(:status)
        .with_values(%w[validating review processing completed completed_with_errors failed cancelled])
    end

throws a failure of

       Expected Task to define :status as an enum backed by an integer, mapping
       ‹"validating"› to ‹0›, ‹"review"› to ‹1›, ‹"processing"› to ‹2›,
       ‹"completed"› to ‹3›, ‹"completed_with_errors"› to ‹4›, ‹"failed"› to
       ‹5›, and ‹"cancelled"› to ‹6›. (we can't tell which).

using shoulda-matcher 5.1.0 this test passes, using 5.2.0 it fails

It appears it is because they changed one of the checks in define_enum_for in 5.1.0
https://github.com/thoughtbot/shoulda-matchers/blob/781ecd06f2611b58585cb4f9d2be38326e88fcc5/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb#L389

to this in 5.2.0
https://github.com/thoughtbot/shoulda-matchers/blob/8a701024bd0a1a3219d1a5786ca3dd928f827436/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb#L423

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant