I think the least brittle way to test for this is to check for unique text in your template that is listed in your i18n locale file. Then, no matter what copy changes you make to copy, you have a reliable check for the content that is relevant to that template.
If youâre using the Flutie gem and the accompanying body_class method, you can also check to see if the right body class (something like .user_profiles-show) has been applied to the document body using Capybara CSS selectors.
thanks for the info. I hoped there was some kind of straightforward way in a feature test, to test for the template. But if I understand you correctly, there is no direct way of testing that you are on the right template in a feature test.
Of course, this doesnât actually check the content of page, only that it renders successfully, so even if your show template was empty this would still pass. But I would expect there to be a test elsewhere that verifies the show behaviour, so for this test verifying that we are on the correct path should be sufficient.
No problem. If youâre very concerned about the template and not so much about the specific content, Iâd just write a very small controller test and check which template was used there. Verifying an implementation detail like this is more of a unit test than an integration test.
I agree with @andyw8 on the Page object. It also feels that the path check should be implicit at your integration level: asserting the proper information is there should imply that you are hitting the correct path.