class BetterHtml::TestHelper::SafeErb::AllowedScriptType

Constants

VALID_JAVASCRIPT_TAG_TYPES

Public Instance Methods

validate() click to toggle source
# File lib/better_html/test_helper/safe_erb/allowed_script_type.rb, line 9
def validate
  script_tags.each do |tag, _|
    validate_type(tag)
  end
end

Private Instance Methods

validate_type(tag) click to toggle source
# File lib/better_html/test_helper/safe_erb/allowed_script_type.rb, line 17
def validate_type(tag)
  return unless type_attribute = tag.attributes['type']
  return if VALID_JAVASCRIPT_TAG_TYPES.include?(type_attribute.value)

  add_error(
    "#{type_attribute.value} is not a valid type, valid types are #{VALID_JAVASCRIPT_TAG_TYPES.join(', ')}",
    location: type_attribute.loc
  )
end