Using has_selector to identify responses

This is more of a “best practices” question.

Earlier, when I was trying to understand what it was I was supposed to
be testing with cucumber, I was advised that I should test for text
elements contained in the response body of the expected output. Now,
what I am wondering is how one accounts for multilingual implementation.

I have hit upon the idea of simply adding special css id selectors to
the templates that identify their use. So, for example, instead of
looking for the word “Registration” I would look for a css selector
id=user_registration.

I know that this will work but, is there another, preferred, way of
handling this situation?

Regards,

On Tue, Jan 13, 2009 at 1:11 PM, James B. [email protected]
wrote:

id=user_registration.
http://rubyforge.org/mailman/listinfo/rspec-users

semantic markup ftw
(so, yes, your way :slight_smile:

On Tue, Jan 13, 2009 at 10:11 PM, James B. [email protected]
wrote:

This is more of a “best practices” question.

I’ll describe a practice that has worked well for me.
(I stopped believing in best practices several years ago :-))

I know that this will work but, is there another, preferred, way of
handling this situation?

I’m developing a multilingual app now. Based on the user’s preferences
it
will display UI elements (text, links etc) in either Norwegian, Nynorsk
(Neo
Norwegian) or** Sámi (the 3 official languages in Norway).

We use Webrat, and for the Cucumber Scenarios we have chosen one
arbitrary
language - Norwegian. (Actually, it’s not that arbitrary - it’s what all
the
developers speak and write). In order to make the scenarios readable for
the
stakeholders we prefer to refer to use the visible text instead of the
DOM
id or names. (This also verifies that the tags have properly
corresponding “for” attributes). So we say (translated):

When I fill in “Drammensveien 1” for “Address (work)”

This is much better than

When I fill in “Drammensveien 1” for “user_work_address”

So what about the other languages? We don’t even think about them in 95%
of
the Cucumber features. We have one feature file that just verifies that
we
get Sámi UI instead of Norwegian when the user sets preferences to that
language. This is to verify that the language switching logic works ok.
We
also have a few RSpec specs to verify the same down at the ActiveRecord
and
Controller level.

HTH,
Aslak