[rspec-users] Specs for Helpers that call render

Peter peter at netsprout.com
Fri Nov 2 20:32:22 EDT 2007

The helper spec I am writing tests a helper method that calls render.

module HelperHelper
   def render_partial
     render :partial => 'partial'

The helper spec.

describe HelperHelper do
   it "should render partial" do
     render_partial.should_not == nil

The output generated

$ spec spec/helpers/home_helper_spec.rb

NoMethodError in 'HelperHelper should render partial'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.render
app/helpers/helper_helper.rb:4:in `render_partial'

Finished in 0.00000 seconds

1 example, 1 failure

I tried adding a before(:each) to setup response, controller, and  
template objects that render would be called on but the error was  
always the same.  I am still uncertain I did this correctly although  
I did spend some time looking at the render definition in the rails  

Is there a standard way of setting up specs for helpers that call  

- Peter

(I apologize if this has already been answered.  We spent a good deal  
of time searching around the web for a solution but came up empty so  

More information about the rspec-users mailing list