validate-website 0.7.1 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -20,7 +20,7 @@
20
20
  validate-website is a web crawler for checking the markup validity with XML
21
21
  Schema / DTD and not found urls (more info doc/validate-website.txt).
22
22
 
23
- validate-website-static check the markup validity of your local documents with
23
+ validate-website-static checks the markup validity of your local documents with
24
24
  XML Schema / DTD (more info doc/validate-website-static.txt).
25
25
 
26
26
  HTML5 support with Validator.nu Web Service.
@@ -62,13 +62,26 @@ HTML5 support with Validator.nu Web Service.
62
62
  66::
63
63
  There are not valid markup and pages not found.
64
64
 
65
- == On your application ==
65
+ == On your application
66
66
 
67
67
  require 'validate_website/validator'
68
68
  body = '<!DOCTYPE html><html></html>'
69
69
  v = ValidateWebsite::Validator.new(Nokogiri::HTML(body), body)
70
70
  v.valid? # => false
71
71
 
72
+ == With RSpec
73
+
74
+ On spec/spec_helper.rb:
75
+
76
+ require 'validate_website/validator'
77
+ require 'validate_website/rspec'
78
+
79
+ On your spec/controllers:
80
+
81
+ it 'should be valid' do
82
+ response.body.should be_w3c_valid
83
+ end
84
+
72
85
  == REQUIREMENTS
73
86
 
74
87
  See validate-website.gemspec file.
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ RSpec::Matchers.define :be_w3c_valid do |expected|
3
+ match do |body|
4
+ @validator = ValidateWebsite::Validator.new(Nokogiri::HTML(body), body)
5
+ @validator.valid?
6
+ end
7
+ failure_message_for_should do |actual|
8
+ @validator.errors
9
+ end
10
+ end
@@ -52,9 +52,7 @@ module ValidateWebsite
52
52
  'Content-Length' => multipart.to_s.bytesize.to_s,
53
53
  }
54
54
  res = http.start {|con| con.post(url.path, multipart.to_s, headers) }
55
- if (el = Nokogiri::XML.parse(res.body).at_css('body p.failure'))
56
- @errors << "HTML5 validator.nu #{el.content}"
57
- end
55
+ @errors = Nokogiri::XML.parse(res.body).css('ol li.error').map(&:content)
58
56
  else
59
57
  # dont have xsd fall back to dtd
60
58
  @doc = Dir.chdir(XHTML_PATH) do
data/spec/core_spec.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require File.expand_path('../spec_helper', __FILE__)
2
3
 
3
4
  describe ValidateWebsite::Core do
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en"><head><link href="http://about.validator.nu/icon.png" rel="icon"><link href="http://about.validator.nu/style.css" rel="stylesheet"><title>Validation results for http://www.google.fr/</title></head><body><h1>Validation results for http://www.google.fr/</h1><form method="get"><fieldset><legend>Validator Input</legend><table><tbody><tr title="The document to validate."><th><label for="doc">Document</label></th><td><input type="url" name="doc" id="doc" pattern="(?:(?:https?://.+)|(?:data:.+))?" title="Absolute IRI (http, https or data only) of the document to be checked." value="http://www.google.fr/"></td></tr><tr title="Override for transfer protocol character encoding declaration."><th><label for="charset">Encoding</label></th><td><select id="charset" name="charset"><option value="">As set by the server/page</option><option value="UTF-8">UTF-8 (Global)</option><option value="UTF-16">UTF-16 (Global)</option><option value="Windows-1250">Windows-1250 (Central European)</option><option value="Windows-1251">Windows-1251 (Cyrillic)</option><option value="Windows-1252">Windows-1252 (Western)</option><option value="Windows-1253">Windows-1253 (Greek)</option><option value="Windows-1254">Windows-1254 (Turkish)</option><option value="Windows-1255">Windows-1255 (Hebrew)</option><option value="Windows-1256">Windows-1256 (Arabic)</option><option value="Windows-1257">Windows-1257 (Baltic)</option><option value="Windows-1258">Windows-1258 (Vietnamese)</option><option value="ISO-8859-1">ISO-8859-1 (Western)</option><option value="ISO-8859-2">ISO-8859-2 (Central European)</option><option value="ISO-8859-3">ISO-8859-3 (South European)</option><option value="ISO-8859-4">ISO-8859-4 (Baltic)</option><option value="ISO-8859-5">ISO-8859-5 (Cyrillic)</option><option value="ISO-8859-6">ISO-8859-6 (Arabic)</option><option value="ISO-8859-7">ISO-8859-7 (Greek)</option><option value="ISO-8859-8">ISO-8859-8 (Hebrew)</option><option value="ISO-8859-9">ISO-8859-9 (Turkish)</option><option value="ISO-8859-13">ISO-8859-13 (Baltic)</option><option value="ISO-8859-15">ISO-8859-15 (Western)</option><option value="KOI8-R">KOI8-R (Russian)</option><option value="TIS-620">TIS-620 (Thai)</option><option value="GBK">GBK (Chinese, simplified)</option><option value="GB18030">GB18030 (Chinese, simplified)</option><option value="Big5">Big5 (Chinese, traditional)</option><option value="Big5-HKSCS">Big5-HKSCS (Chinese, traditional)</option><option value="Shift_JIS">Shift_JIS (Japanese)</option><option value="ISO-2022-JP">ISO-2022-JP (Japanese)</option><option value="EUC-JP">EUC-JP (Japanese)</option><option value="ISO-2022-KR">ISO-2022-KR (Korean)</option><option value="EUC-KR">EUC-KR (Korean)</option></select></td></tr><tr title="Space-separated list of schema IRIs. (Leave blank to let the service guess.)"><th><label for="schema">Schemas</label></th><td><input name="schema" id="schema" pattern="(?:(?:(?:https?://\S+)|(?:data:\S+))(?:\s+(?:(?:https?://\S+)|(?:data:\S+)))*)?" title="Space-separated list of schema IRIs. (Leave blank to let the service guess.)" value=""></td></tr><tr title="Selecting a preset overrides the schema field above."><th><label for="preset">Preset</label></th><td><select id="preset" name="preset"><option value="">None</option><option value="http://s.validator.nu/html5/html5full.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">HTML5 (experimental)</option><option value="http://s.validator.nu/html5/html5full-aria.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">HTML5+ARIA (experimental)</option><option value="http://s.validator.nu/html5-aria-svg-mathml.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">HTML5+ARIA, SVG 1.1 plus MathML 2.0 (experimental)</option><option value="http://s.validator.nu/xhtml10/xhtml-strict.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">HTML 4.01 Strict + IRI / XHTML 1.0 Strict + IRI</option><option value="http://s.validator.nu/xhtml10/xhtml-transitional.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">HTML 4.01 Transitional + IRI / XHTML 1.0 Transitional + IRI</option><option value="http://s.validator.nu/xhtml10/xhtml-frameset.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">HTML 4.01 Frameset + IRI / XHTML 1.0 Frameset + IRI</option><option value="http://s.validator.nu/html5/xhtml5full-xhtml.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">XHTML5 (experimental)</option><option value="http://s.validator.nu/xhtml5-aria-rdf-svg-mathml.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">XHTML5+ARIA, SVG 1.1 plus MathML 2.0 (experimental)</option><option value="http://s.validator.nu/xhtml1-rdf-svg-mathml.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">XHTML 1.0 Strict, SVG 1.1, MathML 2.0 + IRI</option><option value="http://s.validator.nu/xhtml1-ruby-rdf-svg-mathml.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">XHTML 1.0 Strict, Ruby, SVG 1.1, MathML 2.0 + IRI</option><option value="http://s.validator.nu/xhtml10/xhtml-basic.rnc http://s.validator.nu/xhtml10/xhtml.sch http://c.validator.nu/all-html4/">XHTML Basic + IRI</option><option value="http://s.validator.nu/svg-xhtml5-aria-rdf-mathml.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/">SVG 1.1+IRI, XHTML5+ARIA plus MathML 2.0 (experimental)</option></select></td></tr><tr title="The parser to use. Affects HTTP Accept header."><th><label for="parser">Parser</label></th><td><select id="parser" name="parser"><option value="" selected="selected">Automatically from Content-Type</option><option value="xml">XML; don’t load external entities</option><option value="xmldtd">XML; load external entities</option><option value="html">HTML; flavor from doctype</option><option value="html5">HTML5</option><option value="html4">HTML 4.01 Strict</option><option value="html4tr">HTML 4.01 Transitional</option></select></td></tr><tr title="Space-separated list of namespace URIs."><th><label for="nsfilter"><abbr title="XML namespace">XMLNS</abbr>&nbsp;Filter</label></th><td><input name="nsfilter" id="nsfilter" pattern="(?:.+:.+(?:\s+.+:.+)*)?" title="Space-separated namespace URIs for vocabularies to be filtered out."></td></tr><tr title="Disrespect MIME RFCs."><th></th><td><label for="laxtype"><input type="checkbox" name="laxtype" id="laxtype" value="yes"> Be lax about HTTP Content-Type</label></td></tr><tr title="Display a report about the textual alternatives for images."><th></th><td><label for="showimagereport"><input type="checkbox" name="showimagereport" id="showimagereport" value="yes"> Show Image Report</label></td></tr><tr title="Display the markup source of the input document."><th></th><td><label for="showsource"><input type="checkbox" name="showsource" id="showsource" value="yes"> Show Source</label></td></tr><tr><th></th><td><input value="Validate" type="submit" id="submit"></td></tr></tbody></table></fieldset></form><script src="http://about.validator.nu/script.js"></script><ol><li class="info"><p><strong>Info</strong>: <span>The Content-Type was <code>text/html</code>. Using the HTML parser.</span></p></li><li class="info warning"><p><strong>Warning</strong>: <span>Using <code>windows-1252</code> instead of the declared encoding <code>iso-8859-1</code>.</span></p><p class="location"><span class="url">http://www.google.fr/</span></p></li><li class="info"><p><strong>Info</strong>: <span>Using the schema for HTML5+ARIA, SVG 1.1 plus MathML 2.0 (experimental).</span></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">112</span></p><p class="extract"><code>ad="document.f&amp;<b>&amp;</b>document.f.q.f</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">148</span></p><p class="extract"><code>;document.gbqf&amp;<b>&amp;</b>document.gbqf.</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>bgcolor</code> attribute on the <code>body</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">17</span>; to line <span class="last-line">11</span>, column <span class="last-col">239</span></p><p class="extract"><code>pt&gt;&lt;/head&gt;<b>&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f&amp;&amp;docu<span class="snip">…</span>nt.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'" &gt;</b>&lt;texta</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>text</code> attribute on the <code>body</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">17</span>; to line <span class="last-line">11</span>, column <span class="last-col">239</span></p><p class="extract"><code>pt&gt;&lt;/head&gt;<b>&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f&amp;&amp;docu<span class="snip">…</span>nt.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'" &gt;</b>&lt;texta</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>link</code> attribute on the <code>body</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">17</span>; to line <span class="last-line">11</span>, column <span class="last-col">239</span></p><p class="extract"><code>pt&gt;&lt;/head&gt;<b>&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f&amp;&amp;docu<span class="snip">…</span>nt.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'" &gt;</b>&lt;texta</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>vlink</code> attribute on the <code>body</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">17</span>; to line <span class="last-line">11</span>, column <span class="last-col">239</span></p><p class="extract"><code>pt&gt;&lt;/head&gt;<b>&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f&amp;&amp;docu<span class="snip">…</span>nt.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'" &gt;</b>&lt;texta</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>alink</code> attribute on the <code>body</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">17</span>; to line <span class="last-line">11</span>, column <span class="last-col">239</span></p><p class="extract"><code>pt&gt;&lt;/head&gt;<b>&lt;body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f&amp;&amp;docu<span class="snip">…</span>nt.gbqf&amp;&amp;document.gbqf.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo80.png'" &gt;</b>&lt;texta</code></p></li><li class="error"><p><strong>Error</strong>: <span>Element <code>nobr</code> not allowed as child of element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a> in this context. (Suppressing further errors from this subtree.)</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">313</span>; to line <span class="last-line">11</span>, column <span class="last-col">318</span></p><p class="extract"><code>v id=gbar&gt;<b>&lt;nobr&gt;</b>&lt;b cla</code></p><dl><dt>Content model for element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a>:</dt>
3
+ <dd><a href="http://www.whatwg.org/specs/web-apps/current-work/#flow-content">Flow content</a>.</dd>
4
+ </dl></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">397</span></p><p class="extract"><code>.fr/imghp?hl=fr<b>&amp;</b>tab=wi"&gt;Images</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">465</span></p><p class="extract"><code>oogle.fr/?hl=fr<b>&amp;</b>tab=wv"&gt;Vidéos</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">536</span></p><p class="extract"><code>e.fr/maps?hl=fr<b>&amp;</b>tab=wl"&gt;Maps&lt;/</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">606</span></p><p class="extract"><code>.fr/nwshp?hl=fr<b>&amp;</b>tab=wn"&gt;Actual</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">684</span></p><p class="extract"><code>/shopping?hl=fr<b>&amp;</b>tab=wf"&gt;Shoppi</code></p></li><li class="error"><p><strong>Error</strong>: <span>Attribute <code>width</code> not allowed on element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a> at this point.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">896</span>; to line <span class="last-line">11</span>, column <span class="last-col">920</span></p><p class="extract"><code>obr&gt;&lt;/div&gt;<b>&lt;div id=guser width=100%&gt;</b>&lt;nobr&gt;</code></p><dl><dt>Attributes for element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a>:</dt>
5
+ <dd><a href="http://www.whatwg.org/specs/web-apps/current-work/#global-attributes">Global attributes</a></dd>
6
+ </dl></li><li class="error"><p><strong>Error</strong>: <span>Element <code>nobr</code> not allowed as child of element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a> in this context. (Suppressing further errors from this subtree.)</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">921</span>; to line <span class="last-line">11</span>, column <span class="last-col">926</span></p><p class="extract"><code>idth=100%&gt;<b>&lt;nobr&gt;</b>&lt;span </code></p><dl><dt>Content model for element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-div-element"><code>div</code></a>:</dt>
7
+ <dd><a href="http://www.whatwg.org/specs/web-apps/current-work/#flow-content">Flow content</a>.</dd>
8
+ </dl></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1019</span></p><p class="extract"><code>href="/url?sa=p<b>&amp;</b>pref=</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1027</span></p><p class="extract"><code>rl?sa=p&amp;pref=ig<b>&amp;</b>pval=3&amp;q=http:</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1034</span></p><p class="extract"><code>&amp;pref=ig&amp;pval=3<b>&amp;</b>q=http://www.g</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1086</span></p><p class="extract"><code>26source%3Diglk<b>&amp;</b>usg=AFQjCNG3dQ</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1363</span></p><p class="extract"><code>viceLogin?hl=fr<b>&amp;</b>continue=http:</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>center</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1507</span>; to line <span class="last-line">11</span>, column <span class="last-col">1514</span></p><p class="extract"><code>div&gt;&lt;/div&gt;<b>&lt;center&gt;</b>&lt;br cl</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>clear</code> attribute on the <code>br</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1515</span>; to line <span class="last-line">11</span>, column <span class="last-col">1536</span></p><p class="extract"><code>v&gt;&lt;center&gt;<b>&lt;br clear=all id=lgpd&gt;</b>&lt;div i</code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">1814</span></p><p class="extract"><code>ad="window.lol&amp;<b>&amp;</b>lol()"/&gt;&lt;/a&gt;&lt;b</code></p></li><li class="info warning"><p><strong>Warning</strong>: <span>The <code>border</code> attribute is obsolete. Consider specifying <code>img { border: 0; }</code> in CSS instead.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1620</span>; to line <span class="last-line">11</span>, column <span class="last-col">1822</span></p><p class="extract"><code>;oi=ddle"&gt;<b>&lt;img alt="200ème anniversaire de Charles Dickens" title="200ème anniversaire de Charles Dickens" bor<span class="snip">…</span>=0 height=214 src="/logos/2012/dickens-2012-HP.jpg" width=500 id=hplogo onload="window.lol&amp;&amp;lol()"/&gt;</b>&lt;/a&gt;&lt;b</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>cellpadding</code> attribute on the <code>table</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1871</span>; to line <span class="last-line">11</span>, column <span class="last-col">1905</span></p><p class="extract"><code>h" name=f&gt;<b>&lt;table cellpadding=0 cellspacing=0&gt;</b>&lt;tr va</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>cellspacing</code> attribute on the <code>table</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1871</span>; to line <span class="last-line">11</span>, column <span class="last-col">1905</span></p><p class="extract"><code>h" name=f&gt;<b>&lt;table cellpadding=0 cellspacing=0&gt;</b>&lt;tr va</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>valign</code> attribute on the <code>tr</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1906</span>; to line <span class="last-line">11</span>, column <span class="last-col">1920</span></p><p class="extract"><code>spacing=0&gt;<b>&lt;tr valign=top&gt;</b>&lt;td wi</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>width</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1921</span>; to line <span class="last-line">11</span>, column <span class="last-col">1934</span></p><p class="extract"><code>align=top&gt;<b>&lt;td width=25%&gt;</b>&amp;nbsp;</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>align</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1946</span>; to line <span class="last-line">11</span>, column <span class="last-col">1969</span></p><p class="extract"><code>nbsp;&lt;/td&gt;<b>&lt;td align=center nowrap&gt;</b>&lt;input</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>nowrap</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1946</span>; to line <span class="last-line">11</span>, column <span class="last-col">1969</span></p><p class="extract"><code>nbsp;&lt;/td&gt;<b>&lt;td align=center nowrap&gt;</b>&lt;input</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>nowrap</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">2658</span>; to line <span class="last-line">11</span>, column <span class="last-col">2705</span></p><p class="extract"><code>span&gt;&lt;/td&gt;<b>&lt;td nowrap width=25% align=left class="fl sblc"&gt;</b>&lt;a hre</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>width</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">2658</span>; to line <span class="last-line">11</span>, column <span class="last-col">2705</span></p><p class="extract"><code>span&gt;&lt;/td&gt;<b>&lt;td nowrap width=25% align=left class="fl sblc"&gt;</b>&lt;a hre</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>align</code> attribute on the <code>td</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">2658</span>; to line <span class="last-line">11</span>, column <span class="last-col">2705</span></p><p class="extract"><code>span&gt;&lt;/td&gt;<b>&lt;td nowrap width=25% align=left class="fl sblc"&gt;</b>&lt;a hre</code></p></li><li class="error"><p><strong>Error</strong>: <span>The <code>font</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">2952</span>; to line <span class="last-line">11</span>, column <span class="last-col">2967</span></p><p class="extract"><code>prm&gt;&lt;span&gt;<b>&lt;font size="-1"&gt;</b>&lt;span </code></p></li><li class="error"><p><strong>Error</strong>: <span><code>&amp;</code> did not start a character reference. (<code>&amp;</code> probably should have been escaped as <code>&amp;amp;</code>.)</span></p><p class="location">At line <span class="last-line">11</span>, column <span class="last-col">3104</span></p><p class="extract"><code>"google.promos&amp;<b>&amp;</b>google.promos.</code></p></li><li class="error"><p><strong>Error</strong>: <span>Element <code>center</code> not allowed as child of element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-span-element"><code>span</code></a> in this context. (Suppressing further errors from this subtree.)</span></p><p class="location">From line <span class="first-line">15</span>, column <span class="first-col">126</span>; to line <span class="last-line">15</span>, column <span class="last-col">141</span></p><p class="extract"><code>id=footer&gt;<b>&lt;center id=fctr&gt;</b>&lt;div s</code></p><dl><dt>Content model for element <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-span-element"><code>span</code></a>:</dt>
9
+ <dd><a href="http://www.whatwg.org/specs/web-apps/current-work/#phrasing-content">Phrasing content</a>.</dd>
10
+ </dl></li><li class="error"><p><strong>Error</strong>: <span>The <code>center</code> element is obsolete. <a href="http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes" title="About using CSS instead of presentational elements and attributes.">Use CSS instead</a>.</span></p><p class="location">From line <span class="first-line">15</span>, column <span class="first-col">126</span>; to line <span class="last-line">15</span>, column <span class="last-col">141</span></p><p class="extract"><code>id=footer&gt;<b>&lt;center id=fctr&gt;</b>&lt;div s</code></p></li><li class="error"><p><strong>Error</strong>: <span>End of file seen and there were open elements.</span></p><p class="location">From line <span class="first-line">21</span>, column <span class="first-col">1</span>; to line <span class="last-line">21</span>, column <span class="last-col">9</span></p><p class="extract"><code>));<span class="lf" title="Line break">↩</span>})();<span class="lf" title="Line break">↩</span><b>&lt;/script&gt;</b></code></p></li><li class="error"><p><strong>Error</strong>: <span>Unclosed element <code>center</code>.</span></p><p class="location">From line <span class="first-line">11</span>, column <span class="first-col">1507</span>; to line <span class="last-line">11</span>, column <span class="last-col">1514</span></p><p class="extract"><code>div&gt;&lt;/div&gt;<b>&lt;center&gt;</b>&lt;br cl</code></p></li></ol><p class="failure">There were errors.</p><p class="stats">Total execution time 151 milliseconds.</p><hr><p><a href="http://about.validator.nu/">About this Service</a> • <a href="http://html5.validator.nu/">Simplified Interface</a></p></body></html>
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  begin
2
3
  require 'fakeweb'
3
4
  rescue LoadError
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'minitest/autorun'
2
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'fakeweb_helper'))
3
4
  require 'anemone'
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require File.expand_path('../spec_helper', __FILE__)
2
3
 
3
4
  describe ValidateWebsite::Validator do
@@ -50,6 +51,24 @@ describe ValidateWebsite::Validator do
50
51
  validator.valid?.must_equal true
51
52
  end
52
53
  end
54
+ describe('when not valid') do
55
+ before do
56
+ validator_res = File.join('spec', 'data', 'validator.nu-failure.html')
57
+ FakeWeb.register_uri(:any, 'http://validator.nu/',
58
+ :body => open(validator_res).read)
59
+ end
60
+ it 'should have an array of errors' do
61
+ name = 'html5'
62
+ file = File.join('spec', 'data', "#{name}-linuxfr.html")
63
+ page = FakePage.new(name,
64
+ :body => open(file).read,
65
+ :content_type => 'text/html')
66
+ @html5_page = @http.fetch_page(page.url)
67
+ validator = ValidateWebsite::Validator.new(@html5_page.doc, @html5_page.body)
68
+ validator.valid?.must_equal false
69
+ validator.errors.size.must_equal 38
70
+ end
71
+ end
53
72
  end
54
73
 
55
74
  describe('html4') do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate-website
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-25 00:00:00.000000000 Z
12
+ date: 2012-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: anemone
16
- requirement: &14219840 !ruby/object:Gem::Requirement
16
+ requirement: &14096080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.6.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14219840
24
+ version_requirements: *14096080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rainbow
27
- requirement: &14218980 !ruby/object:Gem::Requirement
27
+ requirement: &14094820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *14218980
35
+ version_requirements: *14094820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multipart_body
38
- requirement: &14218400 !ruby/object:Gem::Requirement
38
+ requirement: &14094060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *14218400
46
+ version_requirements: *14094060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &14217660 !ruby/object:Gem::Requirement
49
+ requirement: &14093340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.8.7
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *14217660
57
+ version_requirements: *14093340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: minitest
60
- requirement: &14232420 !ruby/object:Gem::Requirement
60
+ requirement: &14092520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.1.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *14232420
68
+ version_requirements: *14092520
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakeweb
71
- requirement: &14230680 !ruby/object:Gem::Requirement
71
+ requirement: &14091820 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 1.3.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *14230680
79
+ version_requirements: *14091820
80
80
  description: validate-website is a web crawler for checking the markup validity with
81
81
  XML Schema / DTD and not found urls.
82
82
  email: laurent@spkdev.net
@@ -90,6 +90,7 @@ files:
90
90
  - Rakefile
91
91
  - LICENSE
92
92
  - lib/validate_website/validator.rb
93
+ - lib/validate_website/rspec.rb
93
94
  - lib/validate_website/colorful_messages.rb
94
95
  - lib/validate_website/core.rb
95
96
  - lib/validate_website/option_parser.rb
@@ -101,6 +102,7 @@ files:
101
102
  - spec/data/html5.html
102
103
  - spec/data/html4-strict.html
103
104
  - spec/data/validator.nu-success.html
105
+ - spec/data/validator.nu-failure.html
104
106
  - spec/data/html5-linuxfr.html
105
107
  - spec/data/xhtml1-strict.html
106
108
  - spec/example/ruby smalltalk/blockcamp-paris-le-28-novembre.html