camelpunch-markup_validity 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.autotest +23 -0
  2. data/CHANGELOG.rdoc +22 -0
  3. data/Manifest.txt +105 -0
  4. data/README.rdoc +101 -0
  5. data/Rakefile +15 -0
  6. data/lib/markup_validity.rb +12 -0
  7. data/lib/markup_validity/MarkUp.html +1095 -0
  8. data/lib/markup_validity/SCHEMA.html +90 -0
  9. data/lib/markup_validity/assertions.rb +32 -0
  10. data/lib/markup_validity/examples.html +25 -0
  11. data/lib/markup_validity/rspec.rb +77 -0
  12. data/lib/markup_validity/templates.html +15 -0
  13. data/lib/markup_validity/validator.rb +65 -0
  14. data/lib/markup_validity/xframes-1.xsd +166 -0
  15. data/lib/markup_validity/xhtml-access-1.xsd +43 -0
  16. data/lib/markup_validity/xhtml-applet-1.xsd +66 -0
  17. data/lib/markup_validity/xhtml-attribs-1.xsd +67 -0
  18. data/lib/markup_validity/xhtml-base-1.xsd +31 -0
  19. data/lib/markup_validity/xhtml-basic-form-1.xsd +195 -0
  20. data/lib/markup_validity/xhtml-basic-table-1.xsd +169 -0
  21. data/lib/markup_validity/xhtml-basic10-model-1.xsd +385 -0
  22. data/lib/markup_validity/xhtml-basic10-module-redefines-1.xsd +61 -0
  23. data/lib/markup_validity/xhtml-basic10-modules-1.xsd +233 -0
  24. data/lib/markup_validity/xhtml-basic10.xsd +99 -0
  25. data/lib/markup_validity/xhtml-basic11-model-1.xsd +622 -0
  26. data/lib/markup_validity/xhtml-basic11-modules-1.xsd +508 -0
  27. data/lib/markup_validity/xhtml-basic11.xsd +105 -0
  28. data/lib/markup_validity/xhtml-bdo-1.xsd +72 -0
  29. data/lib/markup_validity/xhtml-blkphras-1.xsd +155 -0
  30. data/lib/markup_validity/xhtml-blkpres-1.xsd +32 -0
  31. data/lib/markup_validity/xhtml-blkstruct-1.xsd +44 -0
  32. data/lib/markup_validity/xhtml-charent-1.xsd +38 -0
  33. data/lib/markup_validity/xhtml-copyright-1.xsd +29 -0
  34. data/lib/markup_validity/xhtml-csismap-1.xsd +91 -0
  35. data/lib/markup_validity/xhtml-datatypes-1.xsd +177 -0
  36. data/lib/markup_validity/xhtml-edit-1.xsd +34 -0
  37. data/lib/markup_validity/xhtml-events-1.xsd +130 -0
  38. data/lib/markup_validity/xhtml-form-1.xsd +321 -0
  39. data/lib/markup_validity/xhtml-frames-1.xsd +113 -0
  40. data/lib/markup_validity/xhtml-framework-1.xsd +62 -0
  41. data/lib/markup_validity/xhtml-hypertext-1.xsd +47 -0
  42. data/lib/markup_validity/xhtml-iframe-1.xsd +68 -0
  43. data/lib/markup_validity/xhtml-image-1.xsd +40 -0
  44. data/lib/markup_validity/xhtml-inlphras-1.xsd +158 -0
  45. data/lib/markup_validity/xhtml-inlpres-1.xsd +34 -0
  46. data/lib/markup_validity/xhtml-inlstruct-1.xsd +45 -0
  47. data/lib/markup_validity/xhtml-inlstyle-1.xsd +22 -0
  48. data/lib/markup_validity/xhtml-inputmode-1.xsd +35 -0
  49. data/lib/markup_validity/xhtml-lat1.ent +196 -0
  50. data/lib/markup_validity/xhtml-legacy-1.xsd +97 -0
  51. data/lib/markup_validity/xhtml-link-1.xsd +45 -0
  52. data/lib/markup_validity/xhtml-list-1.xsd +94 -0
  53. data/lib/markup_validity/xhtml-meta-1.xsd +54 -0
  54. data/lib/markup_validity/xhtml-metaAttributes-1.xsd +39 -0
  55. data/lib/markup_validity/xhtml-misc-1.xsd +441 -0
  56. data/lib/markup_validity/xhtml-nameident-1.xsd +63 -0
  57. data/lib/markup_validity/xhtml-notations-1.xsd +69 -0
  58. data/lib/markup_validity/xhtml-object-1.xsd +71 -0
  59. data/lib/markup_validity/xhtml-param-1.xsd +46 -0
  60. data/lib/markup_validity/xhtml-pres-1.xsd +46 -0
  61. data/lib/markup_validity/xhtml-print-1.xsd +85 -0
  62. data/lib/markup_validity/xhtml-print-model-1.xsd +604 -0
  63. data/lib/markup_validity/xhtml-print-modules-1.xsd +422 -0
  64. data/lib/markup_validity/xhtml-rdfa-1.dtd +438 -0
  65. data/lib/markup_validity/xhtml-rdfa-1.xsd +116 -0
  66. data/lib/markup_validity/xhtml-rdfa-model-1.xsd +461 -0
  67. data/lib/markup_validity/xhtml-rdfa-modules-1.xsd +548 -0
  68. data/lib/markup_validity/xhtml-ruby-1.xsd +170 -0
  69. data/lib/markup_validity/xhtml-ruby-basic-1.xsd +84 -0
  70. data/lib/markup_validity/xhtml-script-1.xsd +65 -0
  71. data/lib/markup_validity/xhtml-special.ent +80 -0
  72. data/lib/markup_validity/xhtml-ssismap-1.xsd +38 -0
  73. data/lib/markup_validity/xhtml-struct-1.xsd +85 -0
  74. data/lib/markup_validity/xhtml-style-1.xsd +47 -0
  75. data/lib/markup_validity/xhtml-symbol.ent +237 -0
  76. data/lib/markup_validity/xhtml-table-1.xsd +267 -0
  77. data/lib/markup_validity/xhtml-target-1.xsd +49 -0
  78. data/lib/markup_validity/xhtml-text-1.xsd +62 -0
  79. data/lib/markup_validity/xhtml1-strict.dtd +978 -0
  80. data/lib/markup_validity/xhtml1-strict.xsd +2211 -0
  81. data/lib/markup_validity/xhtml1-transitional.dtd +1201 -0
  82. data/lib/markup_validity/xhtml1-transitional.xsd +2755 -0
  83. data/lib/markup_validity/xhtml11-model-1.xsd +715 -0
  84. data/lib/markup_validity/xhtml11-module-redefines-1.xsd +335 -0
  85. data/lib/markup_validity/xhtml11-modules-1.xsd +605 -0
  86. data/lib/markup_validity/xhtml11.xsd +107 -0
  87. data/lib/markup_validity/xhtml2.xsd +21 -0
  88. data/lib/markup_validity/xml-events-1.xsd +73 -0
  89. data/lib/markup_validity/xml-events-2.xsd +73 -0
  90. data/lib/markup_validity/xml-events-attribs-1.xsd +73 -0
  91. data/lib/markup_validity/xml-events-attribs-2.xsd +75 -0
  92. data/lib/markup_validity/xml-events-copyright-1.xsd +34 -0
  93. data/lib/markup_validity/xml-events-copyright-2.xsd +34 -0
  94. data/lib/markup_validity/xml-handlers-1.xsd +136 -0
  95. data/lib/markup_validity/xml-handlers-2.xsd +98 -0
  96. data/lib/markup_validity/xml-script-1.xsd +38 -0
  97. data/lib/markup_validity/xml.xsd +286 -0
  98. data/spec/matcher_spec.rb +55 -0
  99. data/test/assets/invalid_entity.xhtml +109 -0
  100. data/test/assets/invalid_entity_transitional.xhtml +109 -0
  101. data/test/assets/order.xml +24 -0
  102. data/test/assets/shipment.xsd +33 -0
  103. data/test/helper.rb +96 -0
  104. data/test/test_markup_validity.rb +105 -0
  105. metadata +198 -0
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'markup_validity'
3
+ require 'test/helper'
4
+
5
+ module Spec
6
+ module Matchers
7
+ extend MarkupValidity::TestHelper
8
+ describe "[actual.should] be_xhtml_transitional" do
9
+ it "is transitional xhtml" do
10
+ Matchers.valid_document.should be_xhtml_transitional
11
+ end
12
+
13
+ it "is xhtml" do
14
+ Matchers.valid_document.should be_xhtml
15
+ end
16
+
17
+ it "is strict xhtml" do
18
+ Matchers.valid_document.should be_xhtml_strict
19
+ end
20
+
21
+ it "is not transitional xhtml" do
22
+ Matchers.invalid_document.should_not be_xhtml_transitional
23
+ end
24
+
25
+ it "is not strict xhtml" do
26
+ Matchers.invalid_document.should_not be_xhtml_strict
27
+ end
28
+
29
+ it "is xhtml+rdfa" do
30
+ Matchers.valid_document.should be_xhtml_rdfa
31
+ end
32
+
33
+ it "is no xhtml+rdfa" do
34
+ Matchers.invalid_document.should_not be_xhtml_rdfa
35
+ end
36
+
37
+ XSD = File.read(
38
+ File.expand_path(
39
+ File.join(File.dirname(__FILE__),'..','test','assets','shipment.xsd')
40
+ )
41
+ )
42
+ XML = File.read(
43
+ File.join(File.dirname(__FILE__), '..','test', 'assets', 'order.xml')
44
+ )
45
+
46
+ it "is valid given spec" do
47
+ XML.should be_valid_with_schema XSD
48
+ end
49
+
50
+ it "is not valid given spec" do
51
+ XML.gsub(/<name>[^<]*<\/name>/, '').should_not be_valid_with_schema XSD
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,109 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
6
+ <title>Welcome. It's crantastic!</title>
7
+
8
+ <link href="/stylesheets/application.css?1245016196" media="screen, projection" rel="stylesheet" type="text/css" />
9
+ <link href="/stylesheets/jquery.rating.css?1245016196" media="screen, projection" rel="stylesheet" type="text/css" />
10
+ <link href="/stylesheets/print.css?1245016196" media="print" rel="stylesheet" type="text/css" />
11
+ <!--[if IE]>
12
+ <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
13
+ <![endif]-->
14
+
15
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="/javascripts/jquery.livequery.js?1245016196" type="text/javascript"></script>
16
+ <script src="/javascripts/jquery.MetaData.js?1245016196" type="text/javascript"></script>
17
+ <script src="/javascripts/jquery.delayedObserver.js?1245016196" type="text/javascript"></script>
18
+ <script src="/javascripts/jquery.rating.pack.js?1245016196" type="text/javascript"></script>
19
+ <script src="/javascripts/jquery.validate.pack.js?1245016196" type="text/javascript"></script>
20
+ <script src="/javascripts/application.js?1245016196" type="text/javascript"></script> <script type="text/javascript">
21
+ //<![CDATA[
22
+ window.AUTH_TOKEN = '0VzQJqzXsuP5dw0Etja9QAsM58pR/e2PAdNJHSpuvJ8=';
23
+ //]]>
24
+
25
+ </script>
26
+
27
+
28
+ <meta name="verify-v1" content="YtXicWGGldm5yUfU718DJMAreQ9gf2gtsSCe5VysH10=" />
29
+ </head>
30
+ <body>
31
+
32
+ <div id="container">
33
+ <div id="main">
34
+
35
+ <p>
36
+ Welcome to crantastic, a community site for R packages where you
37
+ can search for, review and tag CRAN packages.
38
+ </p>
39
+ <!-- <h2>What's happening?</h2>
40
+ <p>List of events (ratings?, versions, tags, users?)</p> -->
41
+
42
+ </div>
43
+
44
+ <div id="sidebar">
45
+ <h1 class="title"><a href="/">crantastic!</a></h1>
46
+
47
+ <div class="box">
48
+ <ul>
49
+ <li><a href="/packages">Packages</a></li>
50
+ <li><a href="/authors">Authors</a></li>
51
+
52
+ <li><a href="/reviews">Reviews</a></li>
53
+ <li><a href="/tags">Tags</a></li>
54
+ </ul>
55
+ </div>
56
+
57
+ <div id="search-box" class="box">
58
+ <form action="/search" method="get"> <p style="margin: 0;"><input id="q" name="q" type="text" />
59
+
60
+ <input name="commit" type="submit" value="Search" /></p>
61
+ </form> </div>
62
+
63
+ <div class="box">
64
+ <form action="/session/new" method="get"> <p style="margin: 0;">
65
+ <input name="commit" type="submit" value="Log in" />&nbsp; or &nbsp;<a href="/signup">Sign up!</a>
66
+ </p>
67
+
68
+ </form> </div>
69
+ </div>
70
+
71
+ <div id="footer">
72
+ <p>Brought to you by <a href="http://had.co.nz">Hadley Wickham</a>
73
+ and <a href="http://chrononaut.net/">Bj&oslash;rn M&aelig;land</a>.
74
+ Like it? Hate it? Let me know at
75
+ <a href="mailto:cranatic@gmail.com">cranatic@gmail.com</a>.
76
+ <a href="http://crantastic.org/about">About crantastic</a>.</p>
77
+
78
+ </div>
79
+ </div>
80
+
81
+ <script type="text/javascript">
82
+ var uservoiceJsHost = ("https:" == document.location.protocol) ? "https://uservoice.com" : "http://cdn.uservoice.com";
83
+ document.write(unescape("%3Cscript src='" + uservoiceJsHost + "/javascripts/widgets/tab.js' type='text/javascript'%3E%3C/script%3E"))
84
+ </script>
85
+ <script type="text/javascript">
86
+ UserVoice.Tab.show({
87
+ key: 'crantastic',
88
+ host: 'crantastic.uservoice.com',
89
+ forum: 'general',
90
+ alignment: 'left', /* 'left', 'right' */
91
+ background_color:'#f00',
92
+ text_color: 'white', /* 'white', 'black' */
93
+ hover_color: '#06C',
94
+ lang: 'en' /* 'en', 'de', 'nl', 'es', 'fr' */
95
+ })
96
+ </script>
97
+
98
+ <script type="text/javascript">
99
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
100
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
101
+ </script>
102
+ <script type="text/javascript">
103
+ var pageTracker = _gat._getTracker("UA-67989-10");
104
+ pageTracker._initData();
105
+ pageTracker._trackPageview();
106
+ </script>
107
+
108
+ </body>
109
+ </html>
@@ -0,0 +1,109 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
6
+ <title>Welcome. It's crantastic!</title>
7
+
8
+ <link href="/stylesheets/application.css?1245016196" media="screen, projection" rel="stylesheet" type="text/css" />
9
+ <link href="/stylesheets/jquery.rating.css?1245016196" media="screen, projection" rel="stylesheet" type="text/css" />
10
+ <link href="/stylesheets/print.css?1245016196" media="print" rel="stylesheet" type="text/css" />
11
+ <!--[if IE]>
12
+ <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
13
+ <![endif]-->
14
+
15
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="/javascripts/jquery.livequery.js?1245016196" type="text/javascript"></script>
16
+ <script src="/javascripts/jquery.MetaData.js?1245016196" type="text/javascript"></script>
17
+ <script src="/javascripts/jquery.delayedObserver.js?1245016196" type="text/javascript"></script>
18
+ <script src="/javascripts/jquery.rating.pack.js?1245016196" type="text/javascript"></script>
19
+ <script src="/javascripts/jquery.validate.pack.js?1245016196" type="text/javascript"></script>
20
+ <script src="/javascripts/application.js?1245016196" type="text/javascript"></script> <script type="text/javascript">
21
+ //<![CDATA[
22
+ window.AUTH_TOKEN = '0VzQJqzXsuP5dw0Etja9QAsM58pR/e2PAdNJHSpuvJ8=';
23
+ //]]>
24
+
25
+ </script>
26
+
27
+
28
+ <meta name="verify-v1" content="YtXicWGGldm5yUfU718DJMAreQ9gf2gtsSCe5VysH10=" />
29
+ </head>
30
+ <body>
31
+
32
+ <div id="container">
33
+ <div id="main">
34
+
35
+ <p>
36
+ Welcome to crantastic, a community site for R packages where you
37
+ can search for, review and tag CRAN packages.
38
+ </p>
39
+ <!-- <h2>What's happening?</h2>
40
+ <p>List of events (ratings?, versions, tags, users?)</p> -->
41
+
42
+ </div>
43
+
44
+ <div id="sidebar">
45
+ <h1 class="title"><a href="/">crantastic!</a></h1>
46
+
47
+ <div class="box">
48
+ <ul>
49
+ <li><a href="/packages">Packages</a></li>
50
+ <li><a href="/authors">Authors</a></li>
51
+
52
+ <li><a href="/reviews">Reviews</a></li>
53
+ <li><a href="/tags">Tags</a></li>
54
+ </ul>
55
+ </div>
56
+
57
+ <div id="search-box" class="box">
58
+ <form action="/search" method="get"> <p style="margin: 0;"><input id="q" name="q" type="text" />
59
+
60
+ <input name="commit" type="submit" value="Search" /></p>
61
+ </form> </div>
62
+
63
+ <div class="box">
64
+ <form action="/session/new" method="get"> <p style="margin: 0;">
65
+ <input name="commit" type="submit" value="Log in" />&nbsp; or &nbsp;<a href="/signup">Sign up!</a>
66
+ </p>
67
+
68
+ </form> </div>
69
+ </div>
70
+
71
+ <div id="footer">
72
+ <p>Brought to you by <a href="http://had.co.nz">Hadley Wickham</a>
73
+ and <a href="http://chrononaut.net/">Bj&oslash;rn M&aelig;land</a>.
74
+ Like it? Hate it? Let me know at
75
+ <a href="mailto:cranatic@gmail.com">cranatic@gmail.com</a>.
76
+ <a href="http://crantastic.org/about">About crantastic</a>.</p>
77
+
78
+ </div>
79
+ </div>
80
+
81
+ <script type="text/javascript">
82
+ var uservoiceJsHost = ("https:" == document.location.protocol) ? "https://uservoice.com" : "http://cdn.uservoice.com";
83
+ document.write(unescape("%3Cscript src='" + uservoiceJsHost + "/javascripts/widgets/tab.js' type='text/javascript'%3E%3C/script%3E"))
84
+ </script>
85
+ <script type="text/javascript">
86
+ UserVoice.Tab.show({
87
+ key: 'crantastic',
88
+ host: 'crantastic.uservoice.com',
89
+ forum: 'general',
90
+ alignment: 'left', /* 'left', 'right' */
91
+ background_color:'#f00',
92
+ text_color: 'white', /* 'white', 'black' */
93
+ hover_color: '#06C',
94
+ lang: 'en' /* 'en', 'de', 'nl', 'es', 'fr' */
95
+ })
96
+ </script>
97
+
98
+ <script type="text/javascript">
99
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
100
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
101
+ </script>
102
+ <script type="text/javascript">
103
+ var pageTracker = _gat._getTracker("UA-67989-10");
104
+ pageTracker._initData();
105
+ pageTracker._trackPageview();
106
+ </script>
107
+
108
+ </body>
109
+ </html>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+
3
+ <shiporder orderid="889923"
4
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xsi:noNamespaceSchemaLocation="shiporder.xsd">
6
+ <orderperson>John Smith</orderperson>
7
+ <shipto>
8
+ <name>Ola Nordmann</name>
9
+ <address>Langgt 23</address>
10
+ <city>4000 Stavanger</city>
11
+ <country>Norway</country>
12
+ </shipto>
13
+ <item>
14
+ <title>Empire Burlesque</title>
15
+ <note>Special Edition</note>
16
+ <quantity>1</quantity>
17
+ <price>10.90</price>
18
+ </item>
19
+ <item>
20
+ <title>Hide your heart</title>
21
+ <quantity>1</quantity>
22
+ <price>9.90</price>
23
+ </item>
24
+ </shiporder>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1" ?>
2
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
+
4
+ <xs:element name="shiporder">
5
+ <xs:complexType>
6
+ <xs:sequence>
7
+ <xs:element name="orderperson" type="xs:string"/>
8
+ <xs:element name="shipto">
9
+ <xs:complexType>
10
+ <xs:sequence>
11
+ <xs:element name="name" type="xs:string"/>
12
+ <xs:element name="address" type="xs:string"/>
13
+ <xs:element name="city" type="xs:string"/>
14
+ <xs:element name="country" type="xs:string"/>
15
+ </xs:sequence>
16
+ </xs:complexType>
17
+ </xs:element>
18
+ <xs:element name="item" maxOccurs="unbounded">
19
+ <xs:complexType>
20
+ <xs:sequence>
21
+ <xs:element name="title" type="xs:string"/>
22
+ <xs:element name="note" type="xs:string" minOccurs="0"/>
23
+ <xs:element name="quantity" type="xs:positiveInteger"/>
24
+ <xs:element name="price" type="xs:decimal"/>
25
+ </xs:sequence>
26
+ </xs:complexType>
27
+ </xs:element>
28
+ </xs:sequence>
29
+ <xs:attribute name="orderid" type="xs:string" use="required"/>
30
+ </xs:complexType>
31
+ </xs:element>
32
+
33
+ </xs:schema>
data/test/helper.rb ADDED
@@ -0,0 +1,96 @@
1
+ module MarkupValidity
2
+ module TestHelper
3
+ def valid_document
4
+ <<-eoxhtml
5
+ <html xmlns="http://www.w3.org/1999/xhtml">
6
+ <head>
7
+ <title>hello world</title>
8
+ </head>
9
+ <body>
10
+ </body>
11
+ </html>
12
+ eoxhtml
13
+ end
14
+
15
+ def document_with_no_legend_in_fieldset
16
+ <<-eoxhtml
17
+ <html xmlns="http://www.w3.org/1999/xhtml">
18
+ <head>
19
+ <title>hello world</title>
20
+ </head>
21
+ <body>
22
+ <fieldset>
23
+ <ol>
24
+ <li>Hello</li>
25
+ </ol>
26
+ </fieldset>
27
+ </body>
28
+ </html>
29
+ eoxhtml
30
+ end
31
+
32
+ def invalid_document
33
+ <<-eoxhtml
34
+ <html xmlns="http://www.w3.org/1999/xhtml">
35
+ <head>
36
+ </head>
37
+ <body>
38
+ <p>
39
+ <p>
40
+ Hello
41
+ </p>
42
+ </p>
43
+ </body>
44
+ </html>
45
+ eoxhtml
46
+ end
47
+
48
+ # snippets taken from http://www.w3.org/TR/rdfa-syntax/
49
+ def valid_document_xhtml_rdfa
50
+ <<-eoxhtml
51
+ <html
52
+ xmlns="http://www.w3.org/1999/xhtml"
53
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
54
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
55
+ xmlns:cal="http://www.w3.org/2002/12/cal/ical#"
56
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
57
+ >
58
+ <head>
59
+ <title>My home-page</title>
60
+ <meta property="dc:creator" content="Mark Birbeck" />
61
+ <link rel="foaf:topic" href="http://www.formsPlayer.com/#us" />
62
+ </head>
63
+ <body>
64
+ <div>
65
+ <p>
66
+ I'm holding
67
+ <span property="cal:summary">
68
+ one last summer Barbecue
69
+ </span>,
70
+ on
71
+ <span property="cal:dtstart" content="2007-09-16T16:00:00-05:00"
72
+ datatype="xsd:dateTime">
73
+ September 16th at 4pm
74
+ </span>.
75
+ </p>
76
+
77
+ <a xmlns:cc="http://creativecommons.org/ns#"
78
+ rel="cc:license"
79
+ href="http://creativecommons.org/licenses/by-nc-nd/3.0/">
80
+ Creative Commons License
81
+ </a>.
82
+ </div>
83
+ </body>
84
+ </html>
85
+ eoxhtml
86
+ end
87
+
88
+ def invalid_entity_document
89
+ File.read(File.join(File.dirname(__FILE__), 'assets', 'invalid_entity.xhtml'))
90
+ end
91
+
92
+ def invalid_entity_document_transitional
93
+ File.read(File.join(File.dirname(__FILE__), 'assets', 'invalid_entity_transitional.xhtml'))
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,105 @@
1
+ require "test/unit"
2
+ require 'helper'
3
+ require "markup_validity"
4
+
5
+ class TestMarkupValidity < Test::Unit::TestCase
6
+ include MarkupValidity::TestHelper
7
+
8
+ class FakeUnit
9
+ include MarkupValidity::Assertions
10
+
11
+ attr_reader :assertions
12
+
13
+ def initialize
14
+ @assertions = []
15
+ end
16
+
17
+ def assert *args
18
+ @assertions << args
19
+ end
20
+ end
21
+
22
+ def setup
23
+ @fu = FakeUnit.new
24
+ end
25
+
26
+ def test_strict_invalid_entity_error
27
+ assert_xhtml_strict invalid_entity_document
28
+ end
29
+
30
+ def test_transitional_invalid_entity_error
31
+ assert_xhtml_transitional invalid_entity_document_transitional
32
+ end
33
+
34
+ def test_line_numbers_do_not_roll_over
35
+ validator = MarkupValidity::Validator.new('foo')
36
+ assert !validator.valid?
37
+ assert_no_match(/-1/, validator.inspect)
38
+ end
39
+
40
+ def test_line_numbers_do_not_roll_over_line_1
41
+ validator = MarkupValidity::Validator.new("\nfoo")
42
+ assert !validator.valid?
43
+ assert_no_match(/-1/, validator.inspect)
44
+ end
45
+
46
+ def test_valid_xhtml_transitional
47
+ @fu.assert_xhtml_transitional valid_document
48
+ assert_equal [true, ''], @fu.assertions.first
49
+ assert_xhtml_transitional valid_document
50
+ end
51
+
52
+ def test_valid_xhtml
53
+ @fu.assert_xhtml valid_document
54
+ assert_equal [true, ''], @fu.assertions.first
55
+ end
56
+
57
+ def test_valid_xhtml_strict
58
+ @fu.assert_xhtml_strict valid_document
59
+ assert_equal [true, ''], @fu.assertions.first
60
+ end
61
+
62
+ def test_valid_xhtml_rdfa
63
+ @fu.assert_xhtml_rdfa valid_document_xhtml_rdfa
64
+ assert_equal [true, ''], @fu.assertions.first
65
+ end
66
+
67
+ def test_invalid_xhtml
68
+ @fu.assert_xhtml_transitional invalid_document
69
+ assert_equal false, @fu.assertions.first.first
70
+ assert_match('Missing child element', @fu.assertions.first.last)
71
+ end
72
+
73
+ def test_invalid_xhtml_strict
74
+ @fu.assert_xhtml_strict invalid_document
75
+ assert_equal false, @fu.assertions.first.first
76
+ assert_match('Missing child element', @fu.assertions.first.last)
77
+ end
78
+
79
+ def test_invalid_xhtml_rdfa
80
+ @fu.assert_xhtml_rdfa invalid_document
81
+ assert_equal false, @fu.assertions.first.first
82
+ assert_match('Missing child element', @fu.assertions.first.last)
83
+ end
84
+
85
+ def test_valid_schema
86
+ xsd = File.join(File.dirname(__FILE__), 'assets', 'shipment.xsd')
87
+ xml = File.join(File.dirname(__FILE__), 'assets', 'order.xml')
88
+ @fu.assert_schema File.read(xsd), File.read(xml)
89
+ assert_equal [true, ''], @fu.assertions.first
90
+ end
91
+
92
+ def test_invalid_schema
93
+ xsd = File.join(File.dirname(__FILE__), 'assets', 'shipment.xsd')
94
+ xml = File.read File.join(File.dirname(__FILE__), 'assets', 'order.xml')
95
+ xml.gsub!(/<name>[^<]*<\/name>/, '')
96
+ @fu.assert_schema File.read(xsd), xml
97
+ assert_equal false, @fu.assertions.first.first
98
+ assert_match('This element is not', @fu.assertions.first.last)
99
+ end
100
+
101
+ def test_no_legend_does_not_invalidate
102
+ @fu.assert_xhtml_strict document_with_no_legend_in_fieldset
103
+ assert_equal [true, ''], @fu.assertions.first
104
+ end
105
+ end