Last active
August 29, 2015 14:16
-
-
Save gamov/46054d7b4c28730f04c1 to your computer and use it in GitHub Desktop.
Revisions
-
gamov revised this gist
May 29, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # inspired by http://www.scottraymond.net/2005/9/20/validating-x-html-in-rails/ def assert_valid_markup(markup = @response.body, fragment = false) str = if fragment -
gamov revised this gist
Mar 11, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,7 @@ query = 'fragment=' + CGI.escape(str) + '&output=xml' w3c.post2('/check', query) end unless response['x-w3c-validator-status'] == 'Valid' val_folder = Rails.root.join('tmp').join('validations') val_folder.mkdir -
gamov renamed this gist
Mar 11, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
gamov revised this gist
Mar 11, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # inspired by http://www.scottraymond.net/2005/9/20/validating-x-html-in-rails/ def assert_valid_markup(markup = @response.body, fragment = false) str = if fragment "<!doctype html><head><title>T</title></head><body>#{markup}</body></html>" -
gamov created this gist
Mar 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ def assert_valid_markup(markup = @response.body, fragment = false) str = if fragment "<!doctype html><head><title>T</title></head><body>#{markup}</body></html>" else markup.to_str # .to_str to remove SafeBuffer stuff end require 'net/http' # http://validator.w3.org/docs/api.html response = Net::HTTP.start('validator.w3.org') do |w3c| query = 'fragment=' + CGI.escape(str) + '&output=xml' w3c.post2('/check', query) end # puts "Errors Nbr = #{response['X-W3C-Validator-Errors']}" # puts response.body result in html (save it to tmp?) then report as message below unless response['x-w3c-validator-status'] == 'Valid' val_folder = Rails.root.join('tmp').join('validations') val_folder.mkdir file = val_folder.join("#{Time.now.to_i}.html") File.open(file, 'wb+') {|f| f.write(response.body) } end assert_equal 'Valid', response['x-w3c-validator-status'], "HTML Validation failed, see details here: #{file}" end