In the test-driven videos, when we are interacting with the page through Capybara, we are saying:
click_link 'Add a new todo'
One benefit of this is that if a requirement is that ‘Add a new todo’ should be the content of the link, we are validating that. But let’s say down the line, the requirements change, and adding a new todo is done by clicking a button with a plus sign, or even more simply, the content of the link changes. Our tests would break for something that seems rather minor. It seems like our tests are too coupled to the content of the view, rather than the behavior of the application. Is this a best practice, or should we rather target the ID of the link?
Obviously this is a trivial example, but I guess on a more macro level, should our integration tests follow the exact behavior of a user (explicitly say what the user will see, if that’s possible) or more the behavior of the application?