I'm learning RSpec 2 with Rails 3. In order to set the contents of the tag in the layout for each page, I have a helper that can be used to set the title and then return it:
def page_title(subtitle=nil)
if @title.nil?
@title = ["Site Name"]
end
unless subtitle.nil?
@title << subtitle
end
@title.reverse.join " - "
end
The helper is called from both the layout, where it returns the title, and the individual views, where it sets the title. Now, I want to test in the view specs that the title is being set correctly. Since the layout is not rendered, I have decided to call page_title from the spec and check that the return value is what I expect it to be. However, this doesn't work, and always just returns "Site Name". What should I do?