Re: [rspec-users] Testing Controllers with respond_to?

2008-03-25 Thread Seth Ladd
There is a guideline in TDD that you should test your code and not other people's code. The behaviour you're interested in testing is that of ActionController::Base, not of your code. I, of course, do not want to test Rails. I do, however, want to ensure that I have a block to handle the

Re: [rspec-users] Testing Controllers with respond_to?

2008-03-25 Thread David Chelimsky
On Tue, Mar 25, 2008 at 11:38 AM, Seth Ladd [EMAIL PROTECTED] wrote: There is a guideline in TDD that you should test your code and not other people's code. The behaviour you're interested in testing is that of ActionController::Base, not of your code. I, of course, do not want to

Re: [rspec-users] Testing Controllers with respond_to?

2008-03-25 Thread Matt Berther
Hi Seth, To get around this, are you able to test the response.headers collection? This tests the code that you wrote, rather than the template logic performed by rails. response.headers['Content-Type'].should == text/html Untested, of course... but it may work :) -- Matt Berther

Re: [rspec-users] Testing Controllers with respond_to?

2008-03-25 Thread Tim Glen
To do this, I've typically just add the HTTP_ACCEPT header. I can't remember where I picked this up, but it's does specify a format in your respond_to block: Here's the do_request (and a sample spec) for one of my specs where I'm checking for a generated csv file: def do_request