[rspec-users] rspec render :update

Matt Darby matt at matt-darby.com
Sat Jul 12 10:05:12 EDT 2008


On Jul 11, 2008, at 1:04 PM, Reggie Mr. wrote:

> Hi all,
>
> I'm having trouble with rspec 1.1.4 and rjs
>
> response.should have_rjs   #this should be successful for any rjs
> request; but fails
>
> response.should have_rjs(:replace_html)  #no luck
>
> I have tried mocking the page object, but that also fails.
>
> e.g
> @page = mock('page)
> @page.should_receive(:replace_html)
>
> What's the best practice to validate rjs responses?

I use the ARTS plugin to validate RJS. (http://github.com/richpoirier/arts/tree/master 
)
After you install it, you can do things like:

     it "should render edit template" do
       do_get

       assert_rjs :page, 'error_div', :hide
       assert_rjs :replace_html, "edit_div"
       assert_rjs :visual_effect, :scroll_to, 'edit_div'
       assert_rjs :visual_effect, :highlight, "object_#{@object.id}"
     end

Hope this helps!



More information about the rspec-users mailing list