acop 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -0
- data/lib/acop.rb +34 -4
- data/lib/acop/accessibility.rb +67 -34
- data/lib/acop/rspec_writer.rb +50 -0
- data/lib/acop/version.rb +1 -1
- data/spec/acop_spec.rb +49 -0
- metadata +2 -1
data/README.md
CHANGED
@@ -29,6 +29,15 @@ Specify the url you want accessibility tested
|
|
29
29
|
|
30
30
|
`acop -u http://www.google.com`
|
31
31
|
|
32
|
+
Specify the urls to be tested in a file (new line separated)
|
33
|
+
|
34
|
+
`acop -f ./list_of_urls.txt`
|
35
|
+
|
36
|
+
Scaffold rspec tests for a particular url or list of urls in a file. The gem will create a spec directory(if none exists) from where it is run. In addition it will create a spec file with a describe block for a particular url or list of urls. If the spec file being used already exists, the gem will append to the file.
|
37
|
+
|
38
|
+
`acop -u www.google.com -g rspec`
|
39
|
+
`acop -f list_of_urls -g rspec`
|
40
|
+
|
32
41
|
Checkpoints
|
33
42
|
-----------
|
34
43
|
### Standard Web Programming
|
data/lib/acop.rb
CHANGED
@@ -7,17 +7,36 @@ module Acop
|
|
7
7
|
options = {}
|
8
8
|
|
9
9
|
option_parser = OptionParser.new do |opts|
|
10
|
-
opts.banner = 'Usage: acop
|
10
|
+
opts.banner = 'Usage: acop [options] [values]'
|
11
11
|
|
12
12
|
opts.on('-u', '--url URL', 'Url to be accessibility tested') do |tag|
|
13
13
|
options[:url] = tag
|
14
|
+
options[:url] = "http://" + options[:url] unless options[:url].include?("http")
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on('-f', '--file FILEPATH', "File with a list of urls' to be accessibility tested") do |tag|
|
18
|
+
options[:file] = tag
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on('-g', '--generate TEST_TYPE', "Generate tests of the specified type from the list of urls") do |tag|
|
22
|
+
options[:tests] = tag
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
17
26
|
begin
|
18
27
|
option_parser.parse!
|
19
|
-
raise OptionParser::MissingArgument, "Url should be provided!" if options.keys.empty?
|
20
|
-
raise OptionParser::InvalidArgument, "Url cannot be
|
28
|
+
raise OptionParser::MissingArgument, "Either Url or FilePath should be provided!" if options.keys.empty?
|
29
|
+
raise OptionParser::InvalidArgument, "Both Url and FilePath cannot be specified!" if(options[:url]!=nil and options[:file]!=nil)
|
30
|
+
raise OptionParser::MissingArgument, "Url or file with list of urls should be specified to generate tests" unless(options[:url] or options[:file])
|
31
|
+
if(options[:url]!=nil)
|
32
|
+
raise OptionParser::InvalidArgument, "Url cannot be resolved!" unless valid_url?(options[:url])
|
33
|
+
end
|
34
|
+
if(options[:file]!=nil)
|
35
|
+
raise OptionParser::InvalidArgument, "File does not exist or empty!" unless (file_exists?(options[:file]) and file_has_urls?(options[:file]))
|
36
|
+
end
|
37
|
+
if(options[:tests]!=nil)
|
38
|
+
raise OptionParser::InvalidArgument, "Invalid test type! Currently supports 'rspec'" unless expected_test_type?(options[:tests])
|
39
|
+
end
|
21
40
|
rescue OptionParser::ParseError => e
|
22
41
|
puts e.message
|
23
42
|
puts
|
@@ -30,7 +49,6 @@ module Acop
|
|
30
49
|
|
31
50
|
def self.valid_url?(url)
|
32
51
|
begin
|
33
|
-
url = "http://" + url unless url.include?("http")
|
34
52
|
contents = open(url)
|
35
53
|
return true
|
36
54
|
rescue Exception => e
|
@@ -38,4 +56,16 @@ module Acop
|
|
38
56
|
end
|
39
57
|
end
|
40
58
|
|
59
|
+
def self.file_exists?(file)
|
60
|
+
return File.exists?(file)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.file_has_urls?(file)
|
64
|
+
urls = File.readlines(file, 'r')
|
65
|
+
return urls.size > 0
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.expected_test_type?(test_type)
|
69
|
+
return true if(test_type == "rspec")
|
70
|
+
end
|
41
71
|
end
|
data/lib/acop/accessibility.rb
CHANGED
@@ -1,28 +1,56 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'rexml/document'
|
4
|
+
require File.dirname(__FILE__) + '/rspec_writer.rb'
|
4
5
|
|
5
6
|
module Acop
|
6
7
|
|
7
8
|
class Enforcer
|
8
|
-
attr_reader :ah, :source, :contents
|
9
|
+
attr_reader :ah, :options, :source, :contents
|
9
10
|
|
10
11
|
def initialize(options={})
|
12
|
+
@options = options
|
11
13
|
@ah = Helpers.new
|
12
|
-
|
13
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_url_contents(url)
|
17
|
+
url = URI.parse(url)
|
14
18
|
@source = open(url)
|
15
19
|
@contents = Nokogiri::HTML(@source)
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
|
22
|
+
def formatted_url(url)
|
23
|
+
url = "http://" + url unless url.include?("http")
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
26
|
+
def accessibility_checks
|
27
|
+
if(@options[:url])
|
28
|
+
Acop::RSpecWriter.new(options[:url]) if(options[:tests]=='rspec')
|
29
|
+
error_messages = []
|
30
|
+
length = 30 + @options[:url].length
|
31
|
+
puts "="*length
|
32
|
+
puts("==ACCESSIBILITY ISSUES FOR: #{@options[:url].chomp}==")
|
33
|
+
puts "="*length
|
34
|
+
get_url_contents(@options[:url])
|
35
|
+
self.methods.each do |method|
|
36
|
+
error_messages << (self.public_send(method)) if method[0..5] == "check_"
|
37
|
+
end
|
38
|
+
puts error_messages
|
39
|
+
else
|
40
|
+
urls = File.readlines(@options[:file])
|
41
|
+
urls.each do |url|
|
42
|
+
Acop::RSpecWriter.new(url) if(options[:tests]=='rspec')
|
43
|
+
error_messages = []
|
44
|
+
puts("===============================================")
|
45
|
+
puts("==ACCESSIBILITY ISSUES FOR: #{url.chomp}==")
|
46
|
+
puts("===============================================")
|
47
|
+
get_url_contents(formatted_url(url))
|
48
|
+
self.methods.each do |method|
|
49
|
+
error_messages << (self.public_send(method)) if method[0..5] == "check_"
|
50
|
+
end
|
51
|
+
puts error_messages
|
52
|
+
end
|
23
53
|
end
|
24
|
-
|
25
|
-
puts error_messages
|
26
54
|
end
|
27
55
|
|
28
56
|
def check_image_input_alt(source=@contents)
|
@@ -31,7 +59,7 @@ module Acop
|
|
31
59
|
error_messages = []
|
32
60
|
image_inputs.each do |input|
|
33
61
|
if (@ah.attribute_empty_or_nil(input, "alt") and input.parent.name != "a")
|
34
|
-
error_messages.push("Missing alt text/attribute for image button with id/name: " + (input['name'] || input['id'] || ""))
|
62
|
+
error_messages.push("Line #{input.line}: Missing alt text/attribute for image button with id/name: " + (input['name'] || input['id'] || ""))
|
35
63
|
end
|
36
64
|
end
|
37
65
|
error_messages
|
@@ -42,7 +70,7 @@ module Acop
|
|
42
70
|
error_messages = []
|
43
71
|
image_elements.each do |element|
|
44
72
|
if (@ah.attribute_empty_or_nil(element, "alt") and element.parent.name != "a")
|
45
|
-
error_messages.push("Missing alt text/attribute for image with src: " + element['src'])
|
73
|
+
error_messages.push("Line #{element.line}: Missing alt text/attribute for image with src: " + element['src'])
|
46
74
|
end
|
47
75
|
end
|
48
76
|
error_messages
|
@@ -54,7 +82,7 @@ module Acop
|
|
54
82
|
image_links = []
|
55
83
|
link_elements.each do |link_element|
|
56
84
|
if(link_element['alt'] != "")
|
57
|
-
error_messages.push("Alt Text not empty or nil for image link with src: " + link_element['src'])
|
85
|
+
error_messages.push("Line #{link_element.line}: Alt Text not empty or nil for image link with src: " + link_element['src'])
|
58
86
|
end
|
59
87
|
end
|
60
88
|
error_messages
|
@@ -65,7 +93,7 @@ module Acop
|
|
65
93
|
error_messages = []
|
66
94
|
area_elements.each do |element|
|
67
95
|
if (@ah.attribute_empty_or_nil(element, "alt"))
|
68
|
-
error_messages.push("Missing alt text/attribute for area element with id/name: " + (element['name'] || element['id'] || ""))
|
96
|
+
error_messages.push("Line #{element.line}: Missing alt text/attribute for area element with id/name: " + (element['name'] || element['id'] || ""))
|
69
97
|
end
|
70
98
|
end
|
71
99
|
error_messages
|
@@ -75,8 +103,8 @@ module Acop
|
|
75
103
|
title_element = source.css('title')
|
76
104
|
error_messages = []
|
77
105
|
error_messages.push("Missing title element") if title_element.empty?
|
78
|
-
error_messages.push("Empty title element") if(title_element.first and title_element.first.text == "")
|
79
|
-
error_messages.push("More than 1 title element") if title_element.length > 1
|
106
|
+
error_messages.push("Line #{title_element.first.line}: Empty title element") if(title_element.first and title_element.first.text == "")
|
107
|
+
error_messages.push("Line #{title_element.first.line}: More than 1 title element") if title_element.length > 1
|
80
108
|
|
81
109
|
error_messages
|
82
110
|
end
|
@@ -84,7 +112,8 @@ module Acop
|
|
84
112
|
def check_visual_formatting(source=@contents)
|
85
113
|
error_messages = []
|
86
114
|
%w{b i font center u}.each do |markup_element|
|
87
|
-
|
115
|
+
visual_formatting_fields = source.css(markup_element)
|
116
|
+
error_messages.push("Line #{visual_formatting_fields.first.line}: HTML visual formatting elements being used. Use CSS instead") unless visual_formatting_fields.empty?
|
88
117
|
end
|
89
118
|
error_messages
|
90
119
|
end
|
@@ -94,7 +123,8 @@ module Acop
|
|
94
123
|
iframe_elements = source.css("iframe")
|
95
124
|
error_messages = []
|
96
125
|
if(frame_elements.length > 0 or iframe_elements.length > 0)
|
97
|
-
|
126
|
+
puts @source.readlines.first
|
127
|
+
doctype = REXML::Document.new(@source.readlines.first).doctype
|
98
128
|
error_messages.push("Frames/iFrames present but doctype is missing") unless doctype
|
99
129
|
end
|
100
130
|
error_messages
|
@@ -111,17 +141,20 @@ module Acop
|
|
111
141
|
hyperlinks = source.css("a")
|
112
142
|
error_messages = []
|
113
143
|
hyperlinks.each do |link|
|
114
|
-
error_messages.push("Missing link text for link with href: #{link['href']}") if(link.text==nil or link.text=="")
|
144
|
+
error_messages.push("Line #{link.line}: Missing link text for link with href: #{link['href']}") if(link.text==nil or link.text=="")
|
115
145
|
end
|
116
|
-
hyperlink_text = hyperlinks.collect {|link| link.text }
|
117
|
-
|
146
|
+
hyperlink_text = hyperlinks.collect {|link| link.text.lstrip }
|
147
|
+
duplicate_hyperlink_text = hyperlink_text.select{|link| hyperlink_text.count(link) > 1}.uniq
|
148
|
+
duplicate_hyperlink_text.reject! {|text| text.empty? }
|
149
|
+
error_messages.push("Links should not have duplicate text: #{duplicate_hyperlink_text}") unless(duplicate_hyperlink_text.empty?)
|
118
150
|
error_messages
|
119
151
|
end
|
120
152
|
|
121
153
|
def check_flashing_content(source=@contents)
|
122
154
|
error_messages = []
|
123
155
|
%w{blink marquee}.each do |flashing_element|
|
124
|
-
|
156
|
+
flashing_element_fields = source.css(flashing_element)
|
157
|
+
error_messages.push("Line #{flashing_element_fields.first.line}: Flashing elements such as 'blink' or 'marquee' should not be used") unless flashing_element_fields.empty?
|
125
158
|
end
|
126
159
|
error_messages
|
127
160
|
end
|
@@ -131,8 +164,8 @@ module Acop
|
|
131
164
|
frame_elements = source.css("frame")
|
132
165
|
error_messages = []
|
133
166
|
frame_elements.each do |frame|
|
134
|
-
error_messages.push("Missing frame title element") unless frame['title']
|
135
|
-
error_messages.push("Empty frame title element") if frame['title'] == ""
|
167
|
+
error_messages.push("Line #{frame.line}: Missing frame title element") unless frame['title']
|
168
|
+
error_messages.push("Line #{frame.line}: Empty frame title element") if frame['title'] == ""
|
136
169
|
end
|
137
170
|
error_messages
|
138
171
|
end
|
@@ -141,8 +174,8 @@ module Acop
|
|
141
174
|
iframe_elements = source.css("iframe")
|
142
175
|
error_messages = []
|
143
176
|
iframe_elements.each do |iframe|
|
144
|
-
error_messages.push("Missing iframe title element") unless iframe['title']
|
145
|
-
error_messages.push("Empty iframe title element") if iframe['title'] == ""
|
177
|
+
error_messages.push("Line #{iframe.line}: Missing iframe title element") unless iframe['title']
|
178
|
+
error_messages.push("Line #{iframe.line}: Empty iframe title element") if iframe['title'] == ""
|
146
179
|
end
|
147
180
|
error_messages
|
148
181
|
end
|
@@ -159,11 +192,11 @@ module Acop
|
|
159
192
|
form_fields << form.css(element) unless element_fields.empty?
|
160
193
|
end
|
161
194
|
form_fields.flatten!
|
162
|
-
form_fields.reject {|field| field.attr('
|
195
|
+
form_fields.reject! {|field| field.attr('type') == 'submit' || field.attr('type') == 'reset' || field.attr('type') == 'button' }
|
163
196
|
|
164
197
|
form_fields.each do |field|
|
165
198
|
id = field.attr('id')
|
166
|
-
error_messages.push("Missing label for form field with id/name: " + (id || field.attr('name') || "")) if (labels.select {|label| label['for'].to_s == id.to_s }.size < 1)
|
199
|
+
error_messages.push("Line #{field.line}: Missing label for form field with id/name: " + (id || field.attr('name') || "")) if (labels.select {|label| label['for'].to_s == id.to_s }.size < 1)
|
167
200
|
end
|
168
201
|
end
|
169
202
|
error_messages
|
@@ -180,7 +213,7 @@ module Acop
|
|
180
213
|
input_fields.each do |field|
|
181
214
|
value_present = field.attr('value') != nil and field.attr('value') != ""
|
182
215
|
label_absent = (labels.select {|label| label['for'].to_s == field.attr('id').to_s }.size) < 1
|
183
|
-
error_messages.push("Missing value attribute/label present for input element with id/name: " + (field.attr('id').to_s || field.attr('name') || "")) unless(value_present and label_absent)
|
216
|
+
error_messages.push("Line #{field.line}: Missing value attribute/label present for input element with id/name: " + (field.attr('id').to_s || field.attr('name') || "")) unless(value_present and label_absent)
|
184
217
|
end
|
185
218
|
end
|
186
219
|
error_messages
|
@@ -190,13 +223,13 @@ module Acop
|
|
190
223
|
error_messages = []
|
191
224
|
labels = source.css("label")
|
192
225
|
labels.each do |label|
|
193
|
-
error_messages.push("Missing label text for label with for attribute: #{label['for']}") if (label.text==nil or label.text=="")
|
226
|
+
error_messages.push("Line #{label.line}: Missing label text for label with for attribute: #{label['for']}") if (label.text==nil or label.text=="")
|
194
227
|
end
|
195
228
|
|
196
229
|
%w{legend button}.each do |control|
|
197
230
|
fields = source.css(control)
|
198
231
|
fields.each do |field|
|
199
|
-
error_messages.push("Missing #{control} text for #{control}") if (field.text==nil or field.text=="")
|
232
|
+
error_messages.push("Line #{field.line}: Missing #{control} text for #{control}") if (field.text==nil or field.text=="")
|
200
233
|
end
|
201
234
|
end
|
202
235
|
error_messages
|
@@ -217,7 +250,7 @@ module Acop
|
|
217
250
|
end
|
218
251
|
headings.flatten!
|
219
252
|
headings.each do |heading|
|
220
|
-
error_messages.push("Missing text for #{heading.name} element") if(heading.text==nil or heading.text=="")
|
253
|
+
error_messages.push("Line #{heading.line}: Missing text for #{heading.name} element") if(heading.text==nil or heading.text=="")
|
221
254
|
end
|
222
255
|
error_messages
|
223
256
|
end
|
@@ -246,7 +279,7 @@ module Acop
|
|
246
279
|
tables = source.css("table")
|
247
280
|
|
248
281
|
tables.each do |table|
|
249
|
-
error_messages.push("Missing table summary") if(table['summary'] == nil or table['summary'] == "")
|
282
|
+
error_messages.push("Line #{table.line}: Missing table summary") if(table['summary'] == nil or table['summary'] == "")
|
250
283
|
end
|
251
284
|
error_messages
|
252
285
|
end
|
@@ -257,14 +290,14 @@ module Acop
|
|
257
290
|
|
258
291
|
tables.each do |table|
|
259
292
|
if table.css("th").empty?
|
260
|
-
error_messages.push("Missing table headers for table with summary: " + (table['summary'] || ""))
|
293
|
+
error_messages.push("#{table.line}: Missing table headers for table with summary: " + (table['summary'] || ""))
|
261
294
|
end
|
262
295
|
end
|
263
296
|
|
264
297
|
tables.each do |table|
|
265
298
|
th_elements = table.css("th")
|
266
299
|
th_elements.each do |th|
|
267
|
-
error_messages.push("Missing scope for table header") if (th['scope'] == nil || th['scope'] == "")
|
300
|
+
error_messages.push("Line #{th.line}: Missing scope for table header") if (th['scope'] == nil || th['scope'] == "")
|
268
301
|
end
|
269
302
|
end
|
270
303
|
error_messages
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Acop
|
2
|
+
class RSpecWriter
|
3
|
+
attr_writer :file
|
4
|
+
attr_reader :url
|
5
|
+
|
6
|
+
def initialize(url)
|
7
|
+
@url = url
|
8
|
+
Dir.mkdir("./spec") unless File.exists?("./spec")
|
9
|
+
if File.exists?("./spec/acop_spec.rb")
|
10
|
+
@file = File.open("./spec/acop_accessibility_spec.rb", 'a')
|
11
|
+
append_file(@url)
|
12
|
+
else
|
13
|
+
@file = File.open("./spec/acop_accessibility_spec.rb", 'w')
|
14
|
+
write_file(@url)
|
15
|
+
end
|
16
|
+
close_file
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_file(url)
|
20
|
+
write_rspec(url)
|
21
|
+
end
|
22
|
+
|
23
|
+
def write_file(url)
|
24
|
+
write_requires
|
25
|
+
write_rspec(url)
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_requires
|
29
|
+
@file.puts "require 'rspec/expectations'"
|
30
|
+
end
|
31
|
+
|
32
|
+
def write_rspec(url)
|
33
|
+
@file.puts "describe '#{url.chomp}' do"
|
34
|
+
@file.puts " it 'should pass accessibility tests' do"
|
35
|
+
@file.puts " output = `acop -u #{url.chomp}`"
|
36
|
+
@file.puts " output = output.split(\"\\n\").reject! {|line| line[0] == '='}"
|
37
|
+
@file.puts " puts '== ACCESSIBILITY ISSUES =='"
|
38
|
+
@file.puts " puts output"
|
39
|
+
@file.puts " output.should be_empty"
|
40
|
+
@file.puts " end"
|
41
|
+
@file.puts "end"
|
42
|
+
@file.puts
|
43
|
+
end
|
44
|
+
|
45
|
+
def close_file
|
46
|
+
@file.close
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/lib/acop/version.rb
CHANGED
data/spec/acop_spec.rb
CHANGED
@@ -14,6 +14,7 @@ RSpec.configure do |config|
|
|
14
14
|
it "should not return error messages when no issues with image tags" do
|
15
15
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><input type='image' alt='alt text'/></body></html>", :status => 200)
|
16
16
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
17
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
17
18
|
error_messages = enf.check_image_input_alt
|
18
19
|
error_messages.should be_empty
|
19
20
|
end
|
@@ -21,6 +22,7 @@ RSpec.configure do |config|
|
|
21
22
|
it "should return error messages when alt tags absent from input image elements" do
|
22
23
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><input type='image'/></body></html>", :status => 200)
|
23
24
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
25
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
24
26
|
error_messages = enf.check_image_input_alt
|
25
27
|
error_messages.should_not be_empty
|
26
28
|
error_messages[0].should match("Missing alt text/attribute for image button")
|
@@ -29,6 +31,7 @@ RSpec.configure do |config|
|
|
29
31
|
it "should return error messages when alt tags empty in input image elements" do
|
30
32
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><input type='image' alt=''/></body></html>", :status => 200)
|
31
33
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
34
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
32
35
|
error_messages = enf.check_image_input_alt
|
33
36
|
error_messages.should_not be_empty
|
34
37
|
error_messages[0].should match("Missing alt text/attribute for image button")
|
@@ -37,6 +40,7 @@ RSpec.configure do |config|
|
|
37
40
|
it "should return error messages when alt tags absent from image elements" do
|
38
41
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><img src='www.intuit.com'></body></html>", :status => 200)
|
39
42
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
43
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
40
44
|
error_messages = enf.check_image_alt
|
41
45
|
error_messages.should_not be_empty
|
42
46
|
error_messages[0].should match("Missing alt text/attribute for image with src")
|
@@ -45,6 +49,7 @@ RSpec.configure do |config|
|
|
45
49
|
it "should return error messages when alt tags empty in image elements" do
|
46
50
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><img alt='' src='www.intuit.com'></body></html>", :status => 200)
|
47
51
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
52
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
48
53
|
error_messages = enf.check_image_alt
|
49
54
|
error_messages.should_not be_empty
|
50
55
|
error_messages[0].should match("Missing alt text/attribute for image with src")
|
@@ -53,6 +58,7 @@ RSpec.configure do |config|
|
|
53
58
|
it "should return error messages when alt tags absent from image links" do
|
54
59
|
stub_request(:any, "www.example.com").to_return(:body => "<html><body><img src='www.intuit.com'></body></html>", :status => 200)
|
55
60
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
61
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
56
62
|
error_messages = enf.check_image_alt
|
57
63
|
error_messages.should_not be_empty
|
58
64
|
error_messages[0].should match("Missing alt text/attribute for image with src")
|
@@ -61,6 +67,7 @@ RSpec.configure do |config|
|
|
61
67
|
it "should have alt tags empty in image links" do
|
62
68
|
stub_request(:any, "www.example.com").to_return(:body => "<a class='visually-hidden'><img id='img_link' src='\/try_qbo_free.png' alt=''/>Try QuickBooks Online for Free</a>", :status => 200)
|
63
69
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
70
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
64
71
|
error_messages = enf.check_image_links
|
65
72
|
error_messages.should be_empty
|
66
73
|
end
|
@@ -68,6 +75,7 @@ RSpec.configure do |config|
|
|
68
75
|
it "should return error messages when alt tags not empty in image links" do
|
69
76
|
stub_request(:any, "www.example.com").to_return(:body => "<a class='visually-hidden'><img id='img_link' src='\/try_qbo_free.png' alt='bla bla'/>Try QuickBooks Online for Free</a>", :status => 200)
|
70
77
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
78
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
71
79
|
error_messages = enf.check_image_links
|
72
80
|
error_messages.should_not be_empty
|
73
81
|
error_messages[0].should match("Alt Text not empty or nil for image link with src")
|
@@ -76,6 +84,7 @@ RSpec.configure do |config|
|
|
76
84
|
it "should return error messages when alt tags nil in image links" do
|
77
85
|
stub_request(:any, "www.example.com").to_return(:body => "<a class='visually-hidden'><img id='img_link' src='\/try_qbo_free.png' alt='bla bla'/>Try QuickBooks Online for Free</a>", :status => 200)
|
78
86
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
87
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
79
88
|
error_messages = enf.check_image_links
|
80
89
|
error_messages.should_not be_empty
|
81
90
|
error_messages[0].should match("Alt Text not empty or nil for image link with src")
|
@@ -84,6 +93,7 @@ RSpec.configure do |config|
|
|
84
93
|
it "should return error messages when alt tags not present in area elements" do
|
85
94
|
stub_request(:any, "www.example.com").to_return(:body => "<area shape='rect' coords='0,0,82,126' href='sun.htm'>", :status => 200)
|
86
95
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
96
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
87
97
|
error_messages = enf.check_areas
|
88
98
|
error_messages.should_not be_empty
|
89
99
|
error_messages[0].should match("Missing alt text/attribute for area element")
|
@@ -92,6 +102,7 @@ RSpec.configure do |config|
|
|
92
102
|
it "should return error messages when alt tags empty in area elements" do
|
93
103
|
stub_request(:any, "www.example.com").to_return(:body => "<area shape='rect' coords='0,0,82,126' href='sun.htm' alt=''>", :status => 200)
|
94
104
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
105
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
95
106
|
error_messages = enf.check_areas
|
96
107
|
error_messages.should_not be_empty
|
97
108
|
error_messages[0].should match("Missing alt text/attribute for area element")
|
@@ -100,6 +111,7 @@ RSpec.configure do |config|
|
|
100
111
|
it "should not return error messages when alt tags present in area elements" do
|
101
112
|
stub_request(:any, "www.example.com").to_return(:body => "<area shape='rect' coords='0,0,82,126' href='sun.htm' alt='Sun'>", :status => 200)
|
102
113
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
114
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
103
115
|
error_messages = enf.check_areas
|
104
116
|
error_messages.should be_empty
|
105
117
|
end
|
@@ -107,6 +119,7 @@ RSpec.configure do |config|
|
|
107
119
|
it "should return error messages when title not present" do
|
108
120
|
stub_request(:any, "www.example.com").to_return(:body => "<html><head></head></html>", :status => 200)
|
109
121
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
122
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
110
123
|
error_messages = enf.check_page_title
|
111
124
|
error_messages.should_not be_empty
|
112
125
|
error_messages[0].should match("Missing title element")
|
@@ -115,6 +128,7 @@ RSpec.configure do |config|
|
|
115
128
|
it "should return error messages when title element empty" do
|
116
129
|
stub_request(:any, "www.example.com").to_return(:body => "<html><head><title></title></head></html>", :status => 200)
|
117
130
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
131
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
118
132
|
error_messages = enf.check_page_title
|
119
133
|
error_messages.should_not be_empty
|
120
134
|
error_messages[0].should match("Empty title element")
|
@@ -123,6 +137,7 @@ RSpec.configure do |config|
|
|
123
137
|
it "should return error messages when more than 1 title element" do
|
124
138
|
stub_request(:any, "www.example.com").to_return(:body => "<html><head><title>Some Title</title><title>Another title</title></head></html>", :status => 200)
|
125
139
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
140
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
126
141
|
error_messages = enf.check_page_title
|
127
142
|
error_messages.should_not be_empty
|
128
143
|
error_messages[0].should match("More than 1 title element")
|
@@ -131,6 +146,7 @@ RSpec.configure do |config|
|
|
131
146
|
it "should return no error messages when frameset is not present" do
|
132
147
|
stub_request(:any, "www.example.com").to_return(:body => "<frame src='frame_a.htm' title=''><frame src='frame_b.htm' title='bla'>", :status => 200)
|
133
148
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
149
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
134
150
|
error_messages = enf.check_frame_title
|
135
151
|
error_messages.should be_empty
|
136
152
|
end
|
@@ -138,6 +154,7 @@ RSpec.configure do |config|
|
|
138
154
|
it "should return error messages when frame/iframe present but no doctype" do
|
139
155
|
stub_request(:any, "www.example.com").to_return(:body => "<!DOCTYPE Resource SYSTEM 'foo.dtd'><frameset cols='50%,50%'><frame src='frame_a.htm'/><frame src='frame_b.htm'/></frameset>", :status => 200)
|
140
156
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
157
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
141
158
|
error_messages = enf.check_doctype
|
142
159
|
puts error_messages
|
143
160
|
error_messages.should be_empty
|
@@ -146,6 +163,7 @@ RSpec.configure do |config|
|
|
146
163
|
it "should return error messages when frame does not have a title" do
|
147
164
|
stub_request(:any, "www.example.com").to_return(:body => "<frameset cols='50%,50%'><frame src='frame_a.htm'><frame src='frame_b.htm'></frameset>", :status => 200)
|
148
165
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
166
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
149
167
|
error_messages = enf.check_frame_title
|
150
168
|
error_messages.should_not be_empty
|
151
169
|
error_messages[0].should match("Missing frame title element")
|
@@ -154,6 +172,7 @@ RSpec.configure do |config|
|
|
154
172
|
it "should return error messages when frame title is empty" do
|
155
173
|
stub_request(:any, "www.example.com").to_return(:body => "<frameset cols='50%,50%'><frame src='frame_a.htm' title=''><frame src='frame_b.htm' title='bla'></frameset>", :status => 200)
|
156
174
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
175
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
157
176
|
error_messages = enf.check_frame_title
|
158
177
|
error_messages.should_not be_empty
|
159
178
|
error_messages[0].should match("Empty frame title element")
|
@@ -162,6 +181,7 @@ RSpec.configure do |config|
|
|
162
181
|
it "should return error messages when iframe does not have a title" do
|
163
182
|
stub_request(:any, "www.example.com").to_return(:body => "<iframe src='www.google.com'></iframe>", :status => 200)
|
164
183
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
184
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
165
185
|
error_messages = enf.check_iframe_title
|
166
186
|
error_messages.should_not be_empty
|
167
187
|
error_messages[0].should match("Missing iframe title element")
|
@@ -170,6 +190,7 @@ RSpec.configure do |config|
|
|
170
190
|
it "should return error messages when iframe title is empty" do
|
171
191
|
stub_request(:any, "www.example.com").to_return(:body => "<iframe title='' src='www.google.com'></iframe>", :status => 200)
|
172
192
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
193
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
173
194
|
error_messages = enf.check_iframe_title
|
174
195
|
error_messages.should_not be_empty
|
175
196
|
error_messages[0].should match("Empty iframe title element")
|
@@ -178,6 +199,7 @@ RSpec.configure do |config|
|
|
178
199
|
it "should not return error messages when form elements have labels" do
|
179
200
|
stub_request(:any, "www.example.com").to_return(:body => '<form><textarea id="area" rows="3" cols="10" /><label for="area" /></form>', :status => 200)
|
180
201
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
202
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
181
203
|
error_messages = enf.check_form_labels
|
182
204
|
error_messages.should be_empty
|
183
205
|
end
|
@@ -185,6 +207,7 @@ RSpec.configure do |config|
|
|
185
207
|
it "should return error messages when form elements have labels" do
|
186
208
|
stub_request(:any, "www.example.com").to_return(:body => '<form><textarea id="area" rows="3" cols="10" /></form>', :status => 200)
|
187
209
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
210
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
188
211
|
error_messages = enf.check_form_labels
|
189
212
|
error_messages.should_not be_empty
|
190
213
|
end
|
@@ -192,6 +215,7 @@ RSpec.configure do |config|
|
|
192
215
|
it "should not return error messages when form input (submit|reset|button) elements have value attribs and no labels" do
|
193
216
|
stub_request(:any, "www.example.com").to_return(:body => '<form><input id="in" type="button" value="input_value"/></form>', :status => 200)
|
194
217
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
218
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
195
219
|
error_messages = enf.check_form_inputs
|
196
220
|
error_messages.should be_empty
|
197
221
|
end
|
@@ -199,6 +223,7 @@ RSpec.configure do |config|
|
|
199
223
|
it "should return error messages when form input (submit|reset|button) elements have value attribs and labels" do
|
200
224
|
stub_request(:any, "www.example.com").to_return(:body => '<form><input id="in" type="button" value="input_value"/><label for="in" /></form>', :status => 200)
|
201
225
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
226
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
202
227
|
error_messages = enf.check_form_inputs
|
203
228
|
error_messages.should_not be_empty
|
204
229
|
error_messages[0].should match("Missing value attribute/label present for input element")
|
@@ -207,6 +232,7 @@ RSpec.configure do |config|
|
|
207
232
|
it "should return error messages when form input (submit|reset|button) elements have no value attribs and labels" do
|
208
233
|
stub_request(:any, "www.example.com").to_return(:body => '<form><input id="in" type="button" /><label for="in" /></form>', :status => 200)
|
209
234
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
235
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
210
236
|
error_messages = enf.check_form_inputs
|
211
237
|
error_messages.should_not be_empty
|
212
238
|
error_messages[0].should match("Missing value attribute/label present for input element")
|
@@ -215,6 +241,7 @@ RSpec.configure do |config|
|
|
215
241
|
it "should return error messages when form input (submit|reset|button) elements have no value attribs and no labels" do
|
216
242
|
stub_request(:any, "www.example.com").to_return(:body => '<form><input id="in" type="button" /><label for="in" /></form>', :status => 200)
|
217
243
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
244
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
218
245
|
error_messages = enf.check_form_inputs
|
219
246
|
error_messages.should_not be_empty
|
220
247
|
error_messages[0].should match("Missing value attribute/label present for input element")
|
@@ -223,6 +250,7 @@ RSpec.configure do |config|
|
|
223
250
|
it "should not return error messages when form input other than (submit|reset|button) elements have no value attribs and no labels" do
|
224
251
|
stub_request(:any, "www.example.com").to_return(:body => '<form><input id="in" type="text" /><label for="in" /></form>', :status => 200)
|
225
252
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
253
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
226
254
|
error_messages = enf.check_form_inputs
|
227
255
|
error_messages.should be_empty
|
228
256
|
end
|
@@ -230,6 +258,7 @@ RSpec.configure do |config|
|
|
230
258
|
it "should not return error messages when labels have text" do
|
231
259
|
stub_request(:any, "www.example.com").to_return(:body => '<label for="label1">Label 1</label><label for="label2">Label 2</label>', :status => 200)
|
232
260
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
261
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
233
262
|
error_messages = enf.check_form_control_text
|
234
263
|
error_messages.should be_empty
|
235
264
|
end
|
@@ -237,6 +266,7 @@ RSpec.configure do |config|
|
|
237
266
|
it "should return error messages when labels do not have text" do
|
238
267
|
stub_request(:any, "www.example.com").to_return(:body => '<label for="label1">Label 1</label><label for="label2"></label>', :status => 200)
|
239
268
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
269
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
240
270
|
error_messages = enf.check_form_control_text
|
241
271
|
error_messages.should_not be_empty
|
242
272
|
error_messages[0].should match("Missing label text for label")
|
@@ -245,6 +275,7 @@ RSpec.configure do |config|
|
|
245
275
|
it "should not return error messages when legends have text" do
|
246
276
|
stub_request(:any, "www.example.com").to_return(:body => '<legend>Legend 1</legend>', :status => 200)
|
247
277
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
278
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
248
279
|
error_messages = enf.check_form_control_text
|
249
280
|
error_messages.should be_empty
|
250
281
|
end
|
@@ -252,6 +283,7 @@ RSpec.configure do |config|
|
|
252
283
|
it "should return error messages when legends do not have text" do
|
253
284
|
stub_request(:any, "www.example.com").to_return(:body => '<legend></legend>', :status => 200)
|
254
285
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
286
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
255
287
|
error_messages = enf.check_form_control_text
|
256
288
|
error_messages.should_not be_empty
|
257
289
|
error_messages[0].should match("Missing legend text for legend")
|
@@ -260,6 +292,7 @@ RSpec.configure do |config|
|
|
260
292
|
it "should not return error messages when buttons have text" do
|
261
293
|
stub_request(:any, "www.example.com").to_return(:body => '<button type="button">Button 1</button>', :status => 200)
|
262
294
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
295
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
263
296
|
error_messages = enf.check_form_control_text
|
264
297
|
error_messages.should be_empty
|
265
298
|
end
|
@@ -267,6 +300,7 @@ RSpec.configure do |config|
|
|
267
300
|
it "should return error messages when buttons do not have text" do
|
268
301
|
stub_request(:any, "www.example.com").to_return(:body => '<button type="button"></button>', :status => 200)
|
269
302
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
303
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
270
304
|
error_messages = enf.check_form_control_text
|
271
305
|
error_messages.should_not be_empty
|
272
306
|
error_messages[0].should match("Missing button text for button")
|
@@ -275,6 +309,7 @@ RSpec.configure do |config|
|
|
275
309
|
it "should return error_messages when document does not have level 1 heading" do
|
276
310
|
stub_request(:any, "www.example.com").to_return(:body => '<h2>Heading 2</h2><p><h3>Heading 3</h3></p>', :status => 200)
|
277
311
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
312
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
278
313
|
error_messages = enf.check_h1
|
279
314
|
error_messages.should_not be_empty
|
280
315
|
error_messages[0].should match("Missing heading level 1")
|
@@ -283,6 +318,7 @@ RSpec.configure do |config|
|
|
283
318
|
it "should return error_messages when headings do not have text" do
|
284
319
|
stub_request(:any, "www.example.com").to_return(:body => '<p><h1></h1></p><h2>Heading 2</h2><h3></h3>', :status => 200)
|
285
320
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
321
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
286
322
|
error_messages = enf.check_heading_text
|
287
323
|
error_messages.should_not be_empty
|
288
324
|
error_messages[0].should match("Missing text for h1 element")
|
@@ -292,6 +328,7 @@ RSpec.configure do |config|
|
|
292
328
|
it "should not return error_messages when document has correct heading structure" do
|
293
329
|
stub_request(:any, "www.example.com").to_return(:body => '<body><p><h1>Heading 1</h1><h2>Heading 2</h2><p><h3>Heading 3</h3></p></body>', :status => 200)
|
294
330
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
331
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
295
332
|
error_messages = enf.check_heading_structure
|
296
333
|
error_messages.should be_empty
|
297
334
|
end
|
@@ -299,6 +336,7 @@ RSpec.configure do |config|
|
|
299
336
|
it "should return error_messages when document has incorrect heading structure" do
|
300
337
|
stub_request(:any, "www.example.com").to_return(:body => '<p><h2>Heading 2</h2><h1>Heading 1</h1><p><h3>Heading 3</h3></p>', :status => 200)
|
301
338
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
339
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
302
340
|
error_messages = enf.check_heading_structure
|
303
341
|
error_messages.should_not be_empty
|
304
342
|
error_messages[0].should match("First heading level should be h1")
|
@@ -307,6 +345,7 @@ RSpec.configure do |config|
|
|
307
345
|
it "should return error_messages when document has incorrect heading structure" do
|
308
346
|
stub_request(:any, "www.example.com").to_return(:body => '<p><h1>Heading 1</h1><h3>Heading 3</h3><p><h4>Heading 4</h4></p><h2>Heading 2</h2>', :status => 200)
|
309
347
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
348
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
310
349
|
error_messages = enf.check_heading_structure
|
311
350
|
error_messages.should_not be_empty
|
312
351
|
error_messages[0].should match("Incorrect document heading structure")
|
@@ -315,6 +354,7 @@ RSpec.configure do |config|
|
|
315
354
|
it "should return error_messages when table is missing table headers" do
|
316
355
|
stub_request(:any, "www.example.com").to_return(:body => '<table summary="summary"><tr><td>Data 1</td></tr></table>', :status => 200)
|
317
356
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
357
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
318
358
|
error_messages = enf.check_table_headers
|
319
359
|
error_messages.should_not be_empty
|
320
360
|
error_messages[0].should match("Missing table headers for table with summary: summary")
|
@@ -323,6 +363,7 @@ RSpec.configure do |config|
|
|
323
363
|
it "should return error_messages when table headers are missing scope" do
|
324
364
|
stub_request(:any, "www.example.com").to_return(:body => '<table summary="summary"><th>Table Heading</th><tr><td>Data 1</td></tr></table>', :status => 200)
|
325
365
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
366
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
326
367
|
error_messages = enf.check_table_headers
|
327
368
|
error_messages.should_not be_empty
|
328
369
|
error_messages[0].should match("Missing scope for table header")
|
@@ -331,6 +372,7 @@ RSpec.configure do |config|
|
|
331
372
|
it "should not return error_messages when table headers has scope" do
|
332
373
|
stub_request(:any, "www.example.com").to_return(:body => '<table summary="summary"><th scope="row">Table Heading</th><tr><td>Data 1</td></tr></table>', :status => 200)
|
333
374
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
375
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
334
376
|
error_messages = enf.check_table_headers
|
335
377
|
error_messages.should be_empty
|
336
378
|
end
|
@@ -338,6 +380,7 @@ RSpec.configure do |config|
|
|
338
380
|
it "should return error_messages when table is missing summary" do
|
339
381
|
stub_request(:any, "www.example.com").to_return(:body => '<table><th>Table Heading</th><tr><td>Data 1</td></tr></table>', :status => 200)
|
340
382
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
383
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
341
384
|
error_messages = enf.check_table_summary
|
342
385
|
error_messages.should_not be_empty
|
343
386
|
error_messages[0].should match("Missing table summary")
|
@@ -346,6 +389,7 @@ RSpec.configure do |config|
|
|
346
389
|
it "should return error_messages when html lang attribute is not specified" do
|
347
390
|
stub_request(:any, "www.example.com").to_return(:body => '<html></html>', :status => 200)
|
348
391
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
392
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
349
393
|
error_messages = enf.check_html_lang
|
350
394
|
error_messages.should_not be_empty
|
351
395
|
error_messages[0].should match("Missing lang attribute for html")
|
@@ -354,6 +398,7 @@ RSpec.configure do |config|
|
|
354
398
|
it "should not return error_messages when html lang attribute is specified" do
|
355
399
|
stub_request(:any, "www.example.com").to_return(:body => '<html lang="en"></html>', :status => 200)
|
356
400
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
401
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
357
402
|
error_messages = enf.check_html_lang
|
358
403
|
error_messages.should be_empty
|
359
404
|
end
|
@@ -361,6 +406,7 @@ RSpec.configure do |config|
|
|
361
406
|
it "should return error_messages when html visual formatting elements are used" do
|
362
407
|
stub_request(:any, "www.example.com").to_return(:body => '<body><b>Bold text</b><p><i>Italicized Text</i></p></body>', :status => 200)
|
363
408
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
409
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
364
410
|
error_messages = enf.check_visual_formatting
|
365
411
|
error_messages.should_not be_empty
|
366
412
|
error_messages[0].should match("HTML visual formatting elements being used")
|
@@ -369,6 +415,7 @@ RSpec.configure do |config|
|
|
369
415
|
it "should return error_messages when html flashing elements are used" do
|
370
416
|
stub_request(:any, "www.example.com").to_return(:body => '<body><blink>Blinking text</blink><p><marquee>Marquee Text</marquee></p></body>', :status => 200)
|
371
417
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
418
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
372
419
|
error_messages = enf.check_flashing_content
|
373
420
|
error_messages.should_not be_empty
|
374
421
|
error_messages[0].should match("Flashing elements")
|
@@ -377,6 +424,7 @@ RSpec.configure do |config|
|
|
377
424
|
it "should return error messages when link text is absent" do
|
378
425
|
stub_request(:any, "www.example.com").to_return(:body => '<body><a href="www.google.com"></a></body>', :status => 200)
|
379
426
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
427
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
380
428
|
error_messages = enf.check_hyperlinks
|
381
429
|
error_messages.should_not be_empty
|
382
430
|
error_messages[0].should match("Missing link text for link")
|
@@ -385,6 +433,7 @@ RSpec.configure do |config|
|
|
385
433
|
it "should return error messages when there is duplicate link text" do
|
386
434
|
stub_request(:any, "www.example.com").to_return(:body => '<body><a href="www.google.com">Go to Google</a><p><a href="www.google.com">Go to Google</a></p></body>', :status => 200)
|
387
435
|
enf = Acop::Enforcer.new({:url => "www.example.com"})
|
436
|
+
enf.get_url_contents(enf.formatted_url("www.example.com"))
|
388
437
|
error_messages = enf.check_hyperlinks
|
389
438
|
error_messages.should_not be_empty
|
390
439
|
error_messages[0].should match("Links should not have duplicate text")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- bin/acop
|
92
92
|
- lib/acop.rb
|
93
93
|
- lib/acop/accessibility.rb
|
94
|
+
- lib/acop/rspec_writer.rb
|
94
95
|
- lib/acop/version.rb
|
95
96
|
- spec/acop_spec.rb
|
96
97
|
homepage: https://github.com/eveningsamurai/acop
|