[rspec-users] How to spec a render:update call

Korny Sietsma korny at sietsma.com
Thu Oct 25 03:21:02 EDT 2007


Hi folks.

I'm trying to work out how to verify that a controller has called a
render:update block similar to:
    render :update do |page|
      page.replace_html 'edit', :partial => 'form', :locals => { :operation
=> 'edit', :submit_button_value => 'Update' }
    end

We used to test this with something like:
   response.should render_template("_form")
   response.should have_rjs(:replace_html, 'edit')
... which works, but doesn't validate the parameters.

Then I discovered we could do:
    controller.expect_render(:partial => 'form', :locals => { :operation =>
'edit', :submit_button_value => 'Update' })
This will check the parameters, but doesn't confirm *how* the response was
rendered - there is no checking of ':replace_html', and I'm not sure how to
check for any other rjs calls that don't render a partial.  And, as it is
mocking out the call to "render", "should have_rjs" no longer works.

Any thoughts?  Anyone got a suggestion for a way to check both the
parameters, and the kind of render:update call made?

Thanks.

- Korny

-- 
Kornelis Sietsma  korny at my surname dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071025/91816fdf/attachment.html 


More information about the rspec-users mailing list