[rspec-users] Presentation Testing and CSS ids
lists at ruby-forum.com
Thu Mar 12 09:27:51 EDT 2009
Andrew Premdas wrote:
> The key phrase is semantic meaning. Its good to use CSS to give semantic
> meaning to things that appear on web pages. Not only can these id's or
> classes be useful for using with screen readers, they should be stable
> things that don't change even if the design of the page does. It should
This is an example of my current practice, consequential on the
discussions I have had on this list:
<h2 id="authentication_request">To Proceed Please Authenticate
<label for="user_session_username">User Name</label> <br />
size="30" type="text" />
My intent is that id values are tied to the presentation elements they
deal with, not to the layout they find themselves in. So I test the UI
by calling the ids in webrat, rather than the labels. This will ease
any future transition to I18n.t calls in the templates.
As a side issue, in getting the input box ids to work with label ids as
I specified in the templates, I discovered that I had misread the
FormHelper api. I uncovered my mistake by writing a few tests to
exercise this feature as Rails own test/form_helper_test.rb did not.
The point is that I have submitted these tests as a patch to Rails and
they are awaiting verification for inclusion. Patches require three
reviewers for consideration by the core team. My submission has had one
positive review already. I would appreciate a couple of more. The
lighthouse ticket is 2096.
Posted via http://www.ruby-forum.com/.
More information about the rspec-users