Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Header tag bugfix with page-object

Fixed bug in header tag hierarchy tracking that was revealed when using cheezy's page-object.
Added new spec to feed page-object page into matcher to verify that it would work correctly.
  • Loading branch information...
commit 6739a5c97257c08fdb12454e8dd54b7b3947fd04 1 parent 48d31b2
@frenchroasted authored
View
2  lib/ada_matcher.rb
@@ -113,7 +113,7 @@ def link_window_warning(page)
# hierarchical sequencing.
def htag_hierarchy(page)
e = Array.new
- page_tags = page.elements.to_a.collect {|e| e.tag_name}
+ page_tags = page.elements.to_a.collect {|elem| elem.tag_name}
last_htag_num = 0
for i in 0..(page_tags.size - 1)
View
2  lib/ada_matcher/version.rb
@@ -1,3 +1,3 @@
module AdaMatcher
- VERSION = "0.1.3"
+ VERSION = "0.1.4"
end
View
75 spec/ada_matcher_pageobject_spec.rb
@@ -0,0 +1,75 @@
+require 'rubygems'
+require 'ada_matcher'
+require 'page-object'
+require 'watir-webdriver'
+require 'headless'
+
+PROJECT_BASE_PATH = File.expand_path File.dirname(__FILE__)
+
+class GoodPage
+ include PageObject
+end
+
+class BadPage
+ include PageObject
+end
+
+
+describe "PageObjectAdaMatcher" do
+ before(:all) do
+ @headless = Headless.new
+ @headless.start
+ @browser = Watir::Browser.new
+ end
+
+ after(:all) do
+ @browser.close
+ @headless.destroy
+ end
+
+ before(:each) do
+ end
+
+ after(:each) do
+ end
+
+ it "should pass ADA compliant page using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/good_page.html"
+ good_page = GoodPage.new(@browser)
+ good_page.should meet_ada_requirements
+
+ # can also say:
+ # good_page.should meet_ada_requirements(:all)
+ end
+
+ it "should fail with bad image tags using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/bad_page.html"
+ bad_page = BadPage.new(@browser)
+ bad_page.should_not meet_ada_requirements(:image_alt)
+ end
+
+ it "should fail with bad link tags using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/bad_page.html"
+ bad_page = BadPage.new(@browser)
+ bad_page.should_not meet_ada_requirements(:link_title)
+ end
+
+ it "should fail with new window links without warnings using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/bad_page.html"
+ bad_page = BadPage.new(@browser)
+ bad_page.should_not meet_ada_requirements(:link_window_warning)
+ end
+
+ it "should fail if H(1-6) tags appear out of sequence using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/bad_page.html"
+ bad_page = BadPage.new(@browser)
+ bad_page.should_not meet_ada_requirements(:htag_hierarchy)
+ end
+
+ it "should fail if a Form field exists without a corresponding Label using page-object" do
+ @browser.goto "file://#{PROJECT_BASE_PATH}/../resources/bad_page.html"
+ bad_page = BadPage.new(@browser)
+ bad_page.should_not meet_ada_requirements(:label_for)
+ end
+
+end
View
3  spec/ada_matcher_spec.rb
@@ -8,6 +8,7 @@
@project_base_path = File.expand_path File.dirname(__FILE__) << "../"
@headless = Headless.new
@headless.start
+ # @browser = Watir::Browser.new
@browser = Watir::Browser.new
end
@@ -44,7 +45,7 @@
@browser.should_not meet_ada_requirements(:link_window_warning)
end
- it "should fail if H2-H4 tags exist without lower-index H tags" do
+ it "should fail if H(1-6) tags appear out of sequence" do
@browser.goto "file://#{@project_base_path}/../resources/bad_page.html"
@browser.should_not meet_ada_requirements(:htag_hierarchy)
end
Please sign in to comment.
Something went wrong with that request. Please try again.