RSpec Helper Examples with content_for Calls

On a Rails app I’m building, I have a helper method that makes it easier to have unique page titles on each page using an approach Ryan Bates explains in Railscasts episode #30: Pretty Page Title. I suspect a LOT of Rails developers are using this approach too. Here’s the idea:

Well, I wanted to retroactively write an example for it and how to do it wasn’t immediately obvious to me (‘cause I’m still a n00b). I thought the solution was pretty cool. Once I learned the content_for method was actually a helper method and available via ‘helper’, it came pretty quick. Here’s the rspec example:

That’s it. I don’t know how critical this kind of test is, but at least I learned something while forcing myself to write it.