eco_spec.rb 1.0 KB

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe '.eco files check', :aggregate_failures do
  4. eco_files = Rails.root.glob('**/*.eco')
  5. it 'only runs the test as long as .eco files are present - delete the test once they are gone' do
  6. expect(eco_files.count).to be_positive
  7. end
  8. it 'avoids double HTML encoding' do
  9. eco_files.each do |file| # rubocop:disable RSpec/IteratedExpectation
  10. expect(file).to avoid_double_encoding_t.and(avoid_double_encoding_p)
  11. end
  12. end
  13. matcher :avoid_double_encoding_t do
  14. match { !actual.read.match(%r{<%=\s*@T}) }
  15. failure_message { "#{actual.relative_path_from(Rails.root)} performs incorrect double HTML encoding via '<%= T()', please change it to '<%- @T'" }
  16. end
  17. matcher :avoid_double_encoding_p do
  18. match { !actual.read.match(%r{<%=\s*@P}) }
  19. failure_message { "#{actual.relative_path_from(Rails.root)} performs incorrect double HTML encoding via '<%= P()', please change it to '<%- @P'" }
  20. end
  21. end