Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Different prefixes are not detected by with_prefix #1659

Open
deniciocode opened this issue Jan 17, 2025 · 0 comments
Open

Different prefixes are not detected by with_prefix #1659

deniciocode opened this issue Jan 17, 2025 · 0 comments

Comments

@deniciocode
Copy link

Description

When having two enums with the same string values in two different prefixes
will not be distinguished by with_prefix and the tests pass.

Reproduction Steps

class ContactSuggestion < ApplicationRecord
  STATUSES = { pending: 'pending', denied: 'denied', agreed: 'agreed' }.freeze

  enum :candidate_user_status, STATUSES, prefix: :user
  enum :candidate_contact_status, STATUSES, prefix: :contact
end
describe 'validations' do
  subject(:described_instance) { described_class.new }

  it do
    expect(described_instance).to define_enum_for(:candidate_user_status)
      .with_values(agreed: 'agreed', pending: 'pending', denied: 'denied')
      .with_prefix(:user) 
  end

  it do
    expect(described_instance).to define_enum_for(:candidate_contact_status)
      .with_values(agreed: 'agreed', pending: 'pending', denied: 'denied')
      .with_prefix(:user) # Wrong prefix here
  end
end

Expected behavior

As a user I would expect and hint by a failing spec that points out that candidate_contact_status is not prefixed by :user

Actual behavior

The test passes with not harm or information.

System configuration

shoulda_matchers version: 6.4.0
rails version: 8.0.1
ruby version: 3.3.4

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

No branches or pull requests

1 participant