Testing Google’s Accessible Search with the Ruby Accessibility Analysis Kit

Recently Google Labs released Google Accessible Search – Accessible Web Search for the Visually Challenged. Running the search page (http://labs.google.com/accessible/) through RAAKT (using the online version) yields three errors and the search result page is using tables for layout.  Maybe I am missing something here, but how hard can it be for Google to make sure their search page is using best practices and avoid basic accessibility pitfalls?

Languages Influence Your Thought Process

When I studied social antropology a couple of years ago I never thought that it would influence my future programming endeavours. At that time we looked at theories on how things in our surroundings influence thought processes. One theory is called the Sapir-Whorf hypothesis. It states:

“…there is a systematic relationship between the grammatical categories of the language a person speaks and how that person both understands the world and behaves in it.”

Recently I have found more information on how other people feel programming languages influence how they think (e.g. Paul Graham, Charlie Savage). Maybe this can put an end to the Ruby vs Python debate? Some people will feel that Ruby relates more to their thought process than Python does. And some will feel that Python is superior.

If you like me believe that programming languages influence your thought process the advice in The Pragmatic Programmer: From Journeyman to Master is very relevant:

“Learn at least one new [programming] language every year. Different languages solve the same problems in different ways. By learning several different approaches, you can help broaden your thinking and avoid getting stuck in a rut.”

Others may disagree.

So, what is your next language?

Automated accessibility tests in Ruby on Rails

A couple of days ago I released RAAKT – The Ruby Accessibility Analysis Kit gem (I know, it really needs a better name). RAAKT is a gem that can be used independently of Rails and my plan was to make a Rails plugin that would add a custom assert method that did the check. It turns out that it only takes five lines of code so there is no need for a plugin. So let’s see how you can integrate accessibility checks into your current Rails application.

Install the RAAKT gem

This is a simple step. If you have installed rubygems all you need to do is gem install raakt. This will install the latest version of RAAKT (currently 0.3).

Add the custom assertion

Open the file test_helper.rb in the test folder in your Rails application. Add the following method to the class Test::Unit::TestCase:

[source:ruby]
def assert_basic_accessibility
rt = Raakt::Test.new(@response.body)
result = rt.all
assert result.length == 0, result.collect { |msg| “n” + msg.text + “n” }
end
[/source]

Make sure the raakt module is required by adding “require ‘raakt'” in the top of the file. No we can use assert_basic_accessibility in our functional tests (where view output is available).

Test your views

By adding assert_basic_accessibility to all functional tests that render a complete HTML document you can make sure you don’t create any of the fundamental accessibility errors that plague many applications.

Currently the RAAKT module will do the following tests on your markup:

  1. check_document_structure: Verify that headings are correctly structured (h1 -> h2 etc)
  2. check_tables: Verify that all tables have headers (th elements).
  3. check_for_formatting_elements: Make sure no font, b, i, blink or marquee elements have been used.
  4. check_has_heading: Verify that the document has at least one h1 heading.
  5. check_form: Verifies that all form input fields (except hidden fields) have a corresponding label element.
  6. check_link_text: Verifies that all link elements are unambiguous (two links with different targets should not have the same link text. Yes, that means all your “Edit” links). Use the title attribute to separate links.
  7. check_title: Verify that a non-empty title element is available.
  8. check_frames: If frames are used, verify that each frame has a descriptive title attribute.
  9. check_images: Verify that all images have an alt attribute.
  10. check_refresh: Make sure that no client-side meta refresh is present.
  11. check_for_nested_tables: Verify that no nested tables are present.
  12. check_for_language_info: Make sure the html element has a lang attribute indicating what language your document is in.

Sometime soon I will create documentation on each of the errors that you may recieve and what you can do to correct them. Suggestions and feedback are always welcome on the RAAKT project page.

Porting the Python Accessibility Analysis Kit to Ruby

At RailsConf in Chicago I realized that it would be a good idea to port PAAKT to Ruby and make sure it can be used for automatic accessibility tests in the Rails testing framework. Work has begun and I hope to release it at the end of this summer if all goes well. The project is registered at Rubyforge. Now, all I need is a good name. Maybe RAAKT? Suggestions are welcome.

Exporting Exchange calendars to Apple iCal over HTTP and WebDAV

Update: This code has been integrated and greatly enhanced in the rexchange project by Sam Smoot. Update 2: iCal in Lion supports Exchange and none of this should be required anymore.

Having recently recieved a brand new MacBook Pro from my employer I needed to get basic things such as mail and calendaring working. We use Microsoft Exchange 2003 which is great if everyone is using Outlook. Since I work with various clients I am subjected to their respective firewall policy which typically only allows HTTP(S) traffic. This leaves us with Outlook Web Access (dumbed down interface for everyting but IE). Reading e-mail works fine in OWA. However, the calendar becomes useless as reminders won’t appear.

Unfortunately, Apple’s iCal doesn’t work with Exchange. iCal does, however, store data in the standard icalendar format. Having som experience working with WebDAV access to Exchange (which is available if you can reach OWA) I decided to write an Exchange API in Ruby to read calendar items and convert these to the icalendar format. So, I was about half-way through when I discovered that Sam Smoot had created RExchange. That gave me most of the API:s required for connecting to Exchange.

RExchange did not contain a class for working with appointments (only mail and contacts), so I had to add that. Also, RExchange uses the Time::parse method to convert strings to time representation which doesn’t work for dates after 2037.

Anyway, to export your Exchange calendar to iCal through WebDAV, download the rexport script, unpack the files and modify the rexchange.rb file with your login credentials and OWA URL. Execute rexchange.rb from the terminal. It will create an iCal storage file corestorage.ics in the same directory. This can be opened directly in iCal.

Future options may include a synchronization mode. Suggestions and patches are welcome.

Setting up the Interactive Ruby Shell (IRB) for non-english keyboards on Windows XP

For some reason it is difficult to use the [] and {} characters when using IRB with a non-english keyboard on Windows XP. To get it working together with tab completion:

  1. Create a new environment variable called “HOME” and set it to your user home folder (e.g. C:\Documents and Settings\peterk).
  2. Create a text dcument called “.inputrc” in your user home folder with the following content:
    Ik0tWyI6ICJbIg0KIk0tXSI6ICJdIg0KIk0teyI6ICJ7Ig0KIk0tfSI6ICJ9Ig0KIk0tXCI6ICJcIg0KIk0tfCI6ICJ8Ig0KIk0tQCI6ICJAIg0KIk0tfiI6ICJ+IiA=
  3. Make sure irb.bat is using the –readline option (irb.bat is located in the bin folder of your ruby installation).

That’s it!