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 validating qualifier to enum matcher #1630

Closed matsales28 closed 3 months ago

matsales28 commented 3 months ago

On this commit we add a new qualifier to the define_enum_for matcher called validating. This qualifier is used to test if the enum is being validated or not.

class Issue < ActiveRecord::Base
  enum status: [:open, :closed], validate: true
end

RSpec.describe Issue, type: :model do
  it do
    should define_enum_for(:status).
      validating
  end
end