[rspec-users] Documentation Nit

s.ross cwdinfo at gmail.com
Tue Nov 21 00:57:41 EST 2006

I'm trying to wrap my head around rspec_on_rails and ran into the  
following documentation nit:

-------- what it says --------

You can specify :template, :text, or :action.
controller.should_render :template=>"path/to/template/for/action"
controller.should_render :text=>"expected text"
controller.should_render :action=>"expected_action"

-------- what it means --------

You can specify :template, :text, or :action, depending on how the  
rendering was supposed to happen in your code. So, for example, if  
you planned to render something as text, you would use:

controller.should_render :text => "it's a bird, it's a plane, nope,  
it's a bird alright."

If your controller is expected to render by action (and only by  
action), then then use :action. Here is some controller code:

def index
   render :action => 'list'

and the spec for that:

specify "should render using the list *action*" do
   controller.should_render :action => 'list'

Note that while the above example works properly, the following  
fails, even though you knew the exact correct template name:

specify "should render using the list template" do
   controller.should_render :template => 'users/list'

Useful info? I'm a newbie, so just trying to help out.

More information about the rspec-users mailing list