Testing RJS actions

Hi all !

This is my test:   def test_destroy_xhr     Article.expects(:find).with("1").returns(@article = mock("article"))     @article.expects(:destroy).returns(true)     delete :destroy, :id => 1, :format => :js

    assert_template "destroy.rjs"   end

And my implementation:   def destroy     @article.destroy

    respond_to do |format|       format.html { redirect_to articles_url }       format.js { render }       format.xml { head :ok }     end   end

This fails spectacularly:   1) Failure: test_destroy_xhr(AuthenticatedArticlesControllerTest)     [/home/francois/src/config/../vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb:112:in `assert_template'      /home/francois/src/config/../vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb:109:in `assert_template'      ./test/functional/articles_controller_test.rb:84:in `test_destroy_xhr'      /home/francois/src/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run']: expecting <"destroy.rjs"> but rendering with <nil>

Generally, how do we specify the type of request we are sending to the action ?

Thanks !

Is there any reason why you are not using ARTS? It would be much easier to test rjs if you used it.

Hi !