bbc_mobile_standards 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +4 -0
- data/bbc_mobile_standards.gemspec +29 -0
- data/lib/bbc_mobile_standards/accessibility_validator.rb +32 -0
- data/lib/bbc_mobile_standards/html_validator.rb +39 -0
- data/lib/bbc_mobile_standards/proxy.rb +31 -0
- data/lib/bbc_mobile_standards/version.rb +3 -0
- data/lib/bbc_mobile_standards.rb +65 -0
- data/spec/bbc_mobile_standards/accessibility_validator_spec.rb +178 -0
- data/spec/bbc_mobile_standards/html_validator_spec.rb +57 -0
- data/spec/bbc_mobile_standards/proxy_spec.rb +44 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/validator_spec.rb +83 -0
- metadata +130 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "bbc_mobile_standards/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bbc_mobile_standards"
|
7
|
+
s.version = BBCMobileStandards::VERSION
|
8
|
+
s.authors = ["Matthew Crouch"]
|
9
|
+
s.email = ["matthew.crouch@bbc.co.uk"]
|
10
|
+
s.homepage = "http://www.bbc.co.uk/"
|
11
|
+
s.summary = %q{BBC Mobile Standards validator}
|
12
|
+
s.description = %q{Validates HTML and accessibility. Follows FM&T Standards: http://www.bbc.co.uk/guidelines/futuremedia/technical/semantic_markup.shtml}
|
13
|
+
|
14
|
+
s.rubyforge_project = "bbc_mobile_standards"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "raakt", "~> 0.5.6"
|
22
|
+
s.add_dependency "nokogiri"
|
23
|
+
s.add_dependency "w3c_validators"
|
24
|
+
s.add_dependency "rest-client"
|
25
|
+
|
26
|
+
s.add_development_dependency "rspec"
|
27
|
+
s.add_development_dependency "fakeweb"
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BBCMobileStandards
|
2
|
+
class AccessibilityValidator
|
3
|
+
|
4
|
+
attr_reader :errors
|
5
|
+
|
6
|
+
def initialize(html_string)
|
7
|
+
@html_string = html_string
|
8
|
+
@page = Nokogiri::HTML(@html_string)
|
9
|
+
@errors = []
|
10
|
+
validate_page
|
11
|
+
end
|
12
|
+
|
13
|
+
def valid?
|
14
|
+
true unless @errors.size > 0
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def validate_page
|
20
|
+
rakkt_test = Raakt::Test.new(@html_string)
|
21
|
+
rakkt_test.check_images.map { |e| @errors << e.text }
|
22
|
+
@errors << "Document heading structure is wrong" unless rakkt_test.check_document_structure.size == 0
|
23
|
+
@page.xpath('//img[not(@width) or not(@height)]').map { |img| @errors << "No width or height attribute for #{img.to_s}" }
|
24
|
+
@errors << "Page is using <br> for whitespace" if @page =~ /<br\/>\s*<br\/>/
|
25
|
+
@errors << "Page doesn't have 1 <h1> tag" unless @page.xpath('//h1').size == 1
|
26
|
+
%w(b i big blink marquee s strike tt u center nobr font).each do |tag|
|
27
|
+
@errors << "Page is using <#{tag}>" if @page.xpath("//#{tag}").any?
|
28
|
+
end
|
29
|
+
@page.xpath("//form[not(@type)]").map { |form| @errors << "There is a form without a type tag" }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "w3c_validators"
|
2
|
+
module BBCMobileStandards
|
3
|
+
class HTMLValidator
|
4
|
+
|
5
|
+
attr_reader :valid, :errors
|
6
|
+
|
7
|
+
include W3CValidators
|
8
|
+
|
9
|
+
def initialize(html)
|
10
|
+
@html = html
|
11
|
+
@errors = []
|
12
|
+
w3c_validate_html
|
13
|
+
end
|
14
|
+
|
15
|
+
def valid?
|
16
|
+
self.valid
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def w3c_validate_html
|
22
|
+
results = validator.validate_text(@html)
|
23
|
+
unless results.errors.empty?
|
24
|
+
@errors = results.errors
|
25
|
+
@valid = false
|
26
|
+
else
|
27
|
+
@valid = true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def validator
|
32
|
+
if BBCMobileStandards::Proxy.set?
|
33
|
+
MarkupValidator.new(:proxy_host => BBCMobileStandards::Proxy.host)
|
34
|
+
else
|
35
|
+
MarkupValidator.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BBCMobileStandards
|
2
|
+
class Proxy
|
3
|
+
|
4
|
+
@port = 80
|
5
|
+
@host = nil
|
6
|
+
|
7
|
+
def self.port
|
8
|
+
@port
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.port=(number)
|
12
|
+
@port = number
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.host
|
16
|
+
@host
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.host=(host)
|
20
|
+
@host = host
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.set?
|
24
|
+
unless @host.nil?
|
25
|
+
true
|
26
|
+
else
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "bbc_mobile_standards/version"
|
2
|
+
require "bbc_mobile_standards/proxy"
|
3
|
+
require "bbc_mobile_standards/html_validator"
|
4
|
+
require "bbc_mobile_standards/accessibility_validator"
|
5
|
+
require "rest-client"
|
6
|
+
require "raakt"
|
7
|
+
|
8
|
+
module BBCMobileStandards
|
9
|
+
class << self
|
10
|
+
|
11
|
+
attr_reader :html_errors, :accessibility_errors
|
12
|
+
|
13
|
+
def new(url)
|
14
|
+
@html_errors = []
|
15
|
+
@accessibility_errors = []
|
16
|
+
@valid = true
|
17
|
+
@url = url
|
18
|
+
load_html
|
19
|
+
validate
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?
|
24
|
+
@valid
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_report(file_name)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def load_html
|
34
|
+
set_proxies
|
35
|
+
@html = RestClient.get(@url)
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_proxies
|
39
|
+
if BBCMobileStandards::Proxy.set?
|
40
|
+
RestClient.proxy = BBCMobileStandards::Proxy.host
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate
|
45
|
+
validate_html
|
46
|
+
validate_accessibility
|
47
|
+
end
|
48
|
+
|
49
|
+
def validate_html
|
50
|
+
validator = BBCMobileStandards::HTMLValidator.new(@html)
|
51
|
+
unless validator.valid?
|
52
|
+
@valid = false
|
53
|
+
@html_errors << validator.errors
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def validate_accessibility
|
58
|
+
validator = BBCMobileStandards::HTMLValidator.new(@html)
|
59
|
+
unless validator.valid?
|
60
|
+
@valid = false
|
61
|
+
@accessibility_errors << validator.errors
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BBCMobileStandards::AccessibilityValidator do
|
4
|
+
describe "validating invalid image tags" do
|
5
|
+
before(:each) do
|
6
|
+
@test_html = <<-EOF
|
7
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
8
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
9
|
+
<head>
|
10
|
+
<title>hello world</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>My h1</h1>
|
14
|
+
<h2>My h2</h2>
|
15
|
+
<p>
|
16
|
+
<img src="width_and_height.jpg" width="14" height="14" alt="Image has width and height attributes" />
|
17
|
+
<img src="width.jpg" width="14" alt="Image ONLY has width attribute" />
|
18
|
+
<img src="height.jpg" height="14" alt="Image ONLY has height attribute" />
|
19
|
+
</p>
|
20
|
+
</body>
|
21
|
+
</html>
|
22
|
+
EOF
|
23
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should add 2 errors" do
|
27
|
+
@validator.errors.size.should equal(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "validating document structure" do
|
32
|
+
before(:each) do
|
33
|
+
@test_html = <<-EOF
|
34
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
35
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
36
|
+
<head>
|
37
|
+
<title>hello world</title>
|
38
|
+
</head>
|
39
|
+
<body>
|
40
|
+
<h2>My h2</h2>
|
41
|
+
<h1>My h1</h1>
|
42
|
+
</body>
|
43
|
+
</html>
|
44
|
+
EOF
|
45
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should add 1 errors" do
|
49
|
+
@validator.errors.size.should equal(1)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "validating page has 1 <h1> tag" do
|
54
|
+
before(:each) do
|
55
|
+
@test_html = <<-EOF
|
56
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
57
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
58
|
+
<head>
|
59
|
+
<title>hello world</title>
|
60
|
+
</head>
|
61
|
+
<body>
|
62
|
+
</body>
|
63
|
+
</html>
|
64
|
+
EOF
|
65
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should add 1 errors" do
|
69
|
+
@validator.errors.size.should equal(1)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "validating page no banned tags are used" do
|
74
|
+
before(:each) do
|
75
|
+
@test_html = <<-EOF
|
76
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
77
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
78
|
+
<head>
|
79
|
+
<title>hello world</title>
|
80
|
+
</head>
|
81
|
+
<body>
|
82
|
+
<h1>Horrid HTML</h1>
|
83
|
+
<p>
|
84
|
+
<big><b>Note:</b></big> <i>These tags should never ever be used</i>
|
85
|
+
</p>
|
86
|
+
<marquee>
|
87
|
+
<blink>
|
88
|
+
<s>I said never</s>
|
89
|
+
<tt><u>Never!</u></tt>
|
90
|
+
</blink>
|
91
|
+
</marquee>
|
92
|
+
<p>
|
93
|
+
<center><strike>Line through text</strike></center>
|
94
|
+
</p>
|
95
|
+
<p>
|
96
|
+
<font color="red">Or using Font tags</font>
|
97
|
+
</p>
|
98
|
+
<p>
|
99
|
+
<nobr>Also, don't break text</nobr>
|
100
|
+
</p>
|
101
|
+
</body>
|
102
|
+
</html>
|
103
|
+
EOF
|
104
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should add 12 errors" do
|
108
|
+
@validator.errors.size.should equal(12)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "validating forms, should use type" do
|
113
|
+
before(:each) do
|
114
|
+
@test_html = <<-EOF
|
115
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
116
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
117
|
+
<head>
|
118
|
+
<title>Form Test</title>
|
119
|
+
</head>
|
120
|
+
<body>
|
121
|
+
<h1>Form Test</h1>
|
122
|
+
<form action="">
|
123
|
+
<input type="text" name="some_input" id="some_input" title="Some Input"/>
|
124
|
+
</form>
|
125
|
+
</body>
|
126
|
+
</html>
|
127
|
+
EOF
|
128
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should add 1 errors" do
|
132
|
+
@validator.errors.size.should equal(1)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#valid?" do
|
137
|
+
context "failed accessibility tests" do
|
138
|
+
before(:each) do
|
139
|
+
@test_html = <<-EOF
|
140
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
141
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
142
|
+
<head>
|
143
|
+
<title>hello world</title>
|
144
|
+
</head>
|
145
|
+
<body>
|
146
|
+
</body>
|
147
|
+
</html>
|
148
|
+
EOF
|
149
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should add return false" do
|
153
|
+
@validator.valid?.should be_false
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "passed accessibility tests" do
|
159
|
+
before(:each) do
|
160
|
+
@test_html = <<-EOF
|
161
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
162
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
163
|
+
<head>
|
164
|
+
<title>Test Page</title>
|
165
|
+
</head>
|
166
|
+
<body>
|
167
|
+
<h1>Test Page</h1>
|
168
|
+
</body>
|
169
|
+
</html>
|
170
|
+
EOF
|
171
|
+
@validator = BBCMobileStandards::AccessibilityValidator.new(@test_html)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should add return true" do
|
175
|
+
@validator.valid?.should be_true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BBCMobileStandards::HTMLValidator do
|
4
|
+
context "invalid HTML" do
|
5
|
+
before(:each) do
|
6
|
+
@test_html = <<-EOF
|
7
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
8
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
9
|
+
<head>
|
10
|
+
<title>Testing</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<p>
|
14
|
+
<p>
|
15
|
+
Hello
|
16
|
+
</p>
|
17
|
+
</p>
|
18
|
+
</body>
|
19
|
+
</html>
|
20
|
+
EOF
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return false HTML is invalid" do
|
24
|
+
validation = BBCMobileStandards::HTMLValidator.new(@test_html)
|
25
|
+
validation.valid?.should be_false
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should allow access to the html errors when invalid" do
|
29
|
+
validation = BBCMobileStandards::HTMLValidator.new(@test_html)
|
30
|
+
validation.errors.size.should == 1
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
context "valid HTML" do
|
36
|
+
before(:each) do
|
37
|
+
@test_html = <<-EOF
|
38
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
39
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
40
|
+
<head>
|
41
|
+
<title>Testing</title>
|
42
|
+
</head>
|
43
|
+
<body>
|
44
|
+
<p>
|
45
|
+
Hello
|
46
|
+
</p>
|
47
|
+
</body>
|
48
|
+
</html>
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return true when HTML is valid" do
|
53
|
+
validation = BBCMobileStandards::HTMLValidator.new(@test_html)
|
54
|
+
validation.valid?.should be_true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BBCMobileStandards::Proxy do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
# Reset values to defaults
|
7
|
+
BBCMobileStandards::Proxy.port = 80
|
8
|
+
BBCMobileStandards::Proxy.host = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "setting ports" do
|
12
|
+
it "should return 80 if no port is set" do
|
13
|
+
BBCMobileStandards::Proxy.port.should == 80
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return 443 if port is set to 443" do
|
17
|
+
BBCMobileStandards::Proxy.port = 443
|
18
|
+
BBCMobileStandards::Proxy.port.should == 443
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "setting host" do
|
23
|
+
it "should return nil if no host is set" do
|
24
|
+
BBCMobileStandards::Proxy.host.should == nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return 443 if port is set to 443" do
|
28
|
+
BBCMobileStandards::Proxy.host = "www.google.com"
|
29
|
+
BBCMobileStandards::Proxy.host.should == "www.google.com"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#set?" do
|
34
|
+
|
35
|
+
it "should return false if host is nil" do
|
36
|
+
BBCMobileStandards::Proxy.set?.should be_false
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return true if host is set" do
|
40
|
+
BBCMobileStandards::Proxy.host = "www.google.co.uk"
|
41
|
+
BBCMobileStandards::Proxy.set?.should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BBCMobileStandards do
|
4
|
+
|
5
|
+
let(:set_proxy) { BBCMobileStandards::Proxy.host = "www-cache.reith.bbc.co.uk" }
|
6
|
+
|
7
|
+
describe "invalid html" do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
set_proxy
|
11
|
+
@test_html = <<-EOF
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
13
|
+
<head>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<p>
|
17
|
+
<p>
|
18
|
+
Hello
|
19
|
+
</p>
|
20
|
+
</p>
|
21
|
+
</body>
|
22
|
+
</html>
|
23
|
+
EOF
|
24
|
+
FakeWeb.register_uri(:get, "http://www.bbc.co.uk/news/mobile/", :body => @test_html)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return errors if html is not valid" do
|
28
|
+
results = BBCMobileStandards.new("http://www.bbc.co.uk/news/mobile/")
|
29
|
+
results.valid?.should be_false
|
30
|
+
results.html_errors.size.should equal(1)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "valid html" do
|
35
|
+
|
36
|
+
before(:each) do
|
37
|
+
set_proxy
|
38
|
+
@test_html = <<-EOF
|
39
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
40
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
41
|
+
<head>
|
42
|
+
<title>Testing</title>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<p>
|
46
|
+
Hello
|
47
|
+
</p>
|
48
|
+
</body>
|
49
|
+
</html>
|
50
|
+
EOF
|
51
|
+
FakeWeb.register_uri(:get, "http://www.bbc.co.uk/news/mobile/", :body => @test_html)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return true" do
|
55
|
+
results = BBCMobileStandards.new("http://www.bbc.co.uk/news/mobile/")
|
56
|
+
results.valid?.should be_true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "return accessibility errors" do
|
61
|
+
before(:each) do
|
62
|
+
set_proxy
|
63
|
+
@test_html = <<-EOF
|
64
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
65
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
66
|
+
<head>
|
67
|
+
</head>
|
68
|
+
<body>
|
69
|
+
<h1>Testing</h1>
|
70
|
+
<p>Hello</p>
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
EOF
|
74
|
+
FakeWeb.register_uri(:get, "http://www.bbc.co.uk/news/mobile/", :body => @test_html)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should return true" do
|
78
|
+
results = BBCMobileStandards.new("http://www.bbc.co.uk/news/mobile/")
|
79
|
+
results.accessibility_errors.size.should equal(1)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bbc_mobile_standards
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matthew Crouch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-09 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: raakt
|
16
|
+
requirement: &2151815580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.5.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151815580
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &2151814920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151814920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: w3c_validators
|
38
|
+
requirement: &2151813800 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2151813800
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rest-client
|
49
|
+
requirement: &2151813100 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2151813100
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &2151812260 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2151812260
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakeweb
|
71
|
+
requirement: &2151811300 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2151811300
|
80
|
+
description: ! 'Validates HTML and accessibility. Follows FM&T Standards: http://www.bbc.co.uk/guidelines/futuremedia/technical/semantic_markup.shtml'
|
81
|
+
email:
|
82
|
+
- matthew.crouch@bbc.co.uk
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- Gemfile
|
89
|
+
- Rakefile
|
90
|
+
- bbc_mobile_standards.gemspec
|
91
|
+
- lib/bbc_mobile_standards.rb
|
92
|
+
- lib/bbc_mobile_standards/accessibility_validator.rb
|
93
|
+
- lib/bbc_mobile_standards/html_validator.rb
|
94
|
+
- lib/bbc_mobile_standards/proxy.rb
|
95
|
+
- lib/bbc_mobile_standards/version.rb
|
96
|
+
- spec/bbc_mobile_standards/accessibility_validator_spec.rb
|
97
|
+
- spec/bbc_mobile_standards/html_validator_spec.rb
|
98
|
+
- spec/bbc_mobile_standards/proxy_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/validator_spec.rb
|
101
|
+
homepage: http://www.bbc.co.uk/
|
102
|
+
licenses: []
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project: bbc_mobile_standards
|
121
|
+
rubygems_version: 1.8.10
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: BBC Mobile Standards validator
|
125
|
+
test_files:
|
126
|
+
- spec/bbc_mobile_standards/accessibility_validator_spec.rb
|
127
|
+
- spec/bbc_mobile_standards/html_validator_spec.rb
|
128
|
+
- spec/bbc_mobile_standards/proxy_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- spec/validator_spec.rb
|