I'm having the (seemingly) exact same issue. Were you able to figure this out? I'm relatively new to rspec and my controller code works, but the test is failing. It seems like it is not able to retrieve a method from the stub.
On Feb 28, 7:14 pm, Charley <charley.st...@gmail.com> wrote: > I am not sure if I am properly using the respond to call as you > suggested. Here is what I tried: > it "redirects to the bugs parent project" do > Bug.stub(:find) { mock_bug } > mock_bug.should respond_to :project_id > delete :destroy, :id => "1" > response.should redirect_to(project_path(:id => > mock_bug.project_id)) > end > > And here is the failure message: > 1) BugsController DELETE destroy redirects to the bugs parent project > Failure/Error: delete :destroy, :id => "1" > ActionController::RoutingError: > No route matches > {:action=>"show", :controller=>"projects", :id=>#<Bug:0x514c9fe > @name="Bug_1015">} > > In case it would illustrate my situation better, here is my action: > def destroy > @bug = Bug.find(params[:id]) > bugs_project = @bug.project_id > @bug.destroy > > respond_to do |format| > format.html { redirect_to(project_url(bugs_project)) } > format.xml { head :ok } > end > end > > Any ideas? > > On Feb 28, 8:21 am, Craig Demyanovich <cdemyanov...@gmail.com> wrote: > > > > > > > > > On Sun, Feb 27, 2011 at 10:57 PM, Charley <charley.st...@gmail.com> wrote: > > > ... > > > > it "redirects to the bugs list" do > > > Bug.stub(:find) { mock_bug } > > > delete :destroy, :id => "1" > > > response.should redirect_to(bugs_url) > > > end > > > > This fails for obvious reasons. A bug belongs to a project so the > > > redirect should go to the projects_url("someproject_id_I_dont_know") > > > > I am sure this is a fairly simple and common thing. Can anyone help > > > put me on the right path? > > > Make the mock_bug respond to project_id. Then verify that the request's > > response goes to project_path(:id => mock_bug.project_id). > > > Regards, > > Craig > > > _______________________________________________ > > rspec-users mailing list > > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users