Menu

Published by
Categories: Ruby, Rails, RSpec

When testing helper methods that use Rails’ output buffer (for example by calling concat) with RSpec, be sure to add this to your specs:

before (:each) do
  helper.output_buffer = ""
end

Took me a while to figure this one out. Apparently RSpec doesn’t initialize the output buffer and you end up with a NoMethodError on nil.

Cover medium

Learn how to build SaaS applications!

I’m writing a book on building SaaS applications using Ruby on Rails. Sign up now to get a sneak peek at the outline, and an exclusive discount when it’s ready.

Thanks for checking by, mate! You're already signed up to be notified about the release of the SaaS Guidebook. In the meantime, why don't you check out the current outline of the book?

Download the outline