Jamie's Space

JP

Testing Content_for in Rails 3.x Helpers With RSpec

After having a quick look around the net (and not finding anything up to date and useful) I came up with the following basic test structure for testing my ApplicationHelper methods that served up content_for things like page titles, javascript includes, etc:

require 'spec_helper'

describe ApplicationHelper do
  describe "title" do
    it "should call content_for(:title) with the title passed" do
      helper.title("title stuff")
      helper.content_for(:title).should == "title stuff"
    end
  end
end