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 ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Is there any reason why you are not using ARTS? It would be much easier to test rjs if you used it. On 2/6/07, Francois Beausoleil <francois.beausoleil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all ! > > This is my test: > def test_destroy_xhr > Article.expects(:find).with("1").returns(@article = mock("article")) > @article.expects(:destroy).returns(true)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi ! 2007/2/6, Bala Paranj <bcparanj@gmail.com>:> Is there any reason why you are not using ARTS? It would be much > easier to test rjs if you used it.I don't want to test the actual contents of the RJS. I just want to ensure that the proper template was rendered. That's enough for me. Thanks for your reply. Bye ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---