For integration testing, I check content of pages, to make sure user would see what I want.
For example:
it "shows list of articles" do
get :articles
response.body.should have_content("Articles found:")
end
Somewhere in articles view, there is this line:
<h1>Articles found:</h1>
I want to get rid of strings duplicity, make the code easier to maintain and tests more solid. I’m considering putting those strings into config/locales/en.yml and then do something like this
it "shows list of articles" do
get :articles
response.body.should have_content(I18n.t('title'))
end
and in the view:
<h1><%=t :title %></h1>
Does it make sense from long term perspective or is there a better/standardized way?
I wouldn’t, internationalized strings are meant for humans to read.
As an alternative, see if you can structure the document in a way that makes asserting by selects more deterministic.
And in the view.
While I understand that your original test case asserts the presence of a correct title, I would argue that the greatest benefit for a general integration test like this is the presence of a title.