model.rb 509 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module ZammadSpecSupportModel
  3. extend RSpec::Matchers::DSL
  4. matcher :have_validator do
  5. chain(:on, :attribute)
  6. match do
  7. actual
  8. .validators_on(@attribute)
  9. .any?(expected)
  10. end
  11. failure_message do
  12. %(expected #{actual.name} to use #{expected.name} to validate value of #{@attribute})
  13. end
  14. end
  15. end
  16. RSpec.configure do |config|
  17. config.include ZammadSpecSupportModel, type: :model
  18. end