[rspec-users] specifying output of render call

Matt McNeil nabble.108 at xoxy.net
Mon May 5 20:18:02 EDT 2008

Hello again,

First of all, thanks much for everyone's input on my question last week
about spec'ing an invocation of super.  

Here's another question that seems resistant to my Google searching:

With this helper method (defined in a module and included in Rails

def render_rjs_redirect(url = '/')
  render :update do |page|
    page << "location.href='#{url}'"

Is it possible/advisable to specify either the block passed to render or the
output of the helper, something like below?  The only way I have been able
so far to spec this was to create a FooController with an index action that
called the method and then checked the response.body, but that seems like a
lot of overhead to test such a simple method.  Is there a better or obvious
way to do this?


it "should render javascript to redirect the browser" do
  self.should_receive(:render).with(:update) { |page| page <<

it "should render javascript to redirect the browser" do
  response.body.should == "location.href='example.com'"

View this message in context: http://www.nabble.com/specifying-output-of-render-call-tp17071496p17071496.html
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list