Skip to content

Instantly share code, notes, and snippets.

@alex-min
Created April 29, 2016 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-min/cc3e3b71d5909a7ac67317af491a3e0b to your computer and use it in GitHub Desktop.
Save alex-min/cc3e3b71d5909a7ac67317af491a3e0b to your computer and use it in GitHub Desktop.
require 'html_validation'
include PageValidations
HaveValidHTML.show_html_in_failures = true
HTMLValidation.ignored_attribute_errors = ['moznomarginboxes', 'mozdisallowselectionprint']
Capybara::Session.class_eval do
alias :no_html_validation_visit :visit
def visit(visit_url)
result = no_html_validation_visit(visit_url)
if driver.response_headers['Content-Type'].include?('text/html')
html_validator = PageValidations::HTMLValidation.new
validation = html_validator.validation(html, visit_url)
unless validation.valid?
path = Rails.application.routes.recognize_path(current_url)
raise "HTML Validation Error on #{path[:controller]}/#{path[:action]}.html.erb\n"\
"#{validation.exceptions}"
end
end
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment