On Mar 24, 3:21 pm, Joshua M. email@example.com
Sadly Rails does not automatically create ID attrs for many tags like
links or buttons.
Has this a special reason? Or is it safe to customize the link_to etc.
helpers so they create ID’s automatically?
No special reason, other than how would Rails generate the IDs in a
predictable fashion? If you are not (or can not) cache the generated
html from a template, then the template will be evaluated each time
form the server, so Rails would have to have some way of making sure
all the IDs it generates are unique across the page - perhaps unique
across the whole app depending on what you’re testing. Not to
mention, you would probably want Rails to use the same IDs for the
same elements each time so your tests don’t break… So I think you
can see it’s not one of those no-brainers that it might seem to be.
Why don’t you just specify the ID yourself for the elements that need
it? It’s pretty easy to add your own HTML IDs to all of your link_to
statements, or like you said, create your own helper that will do it