Hi Jon,
Thanks for your response. I’m going to assume that you are correct that this test belongs in a request spec, not a controller spec (because the other answer I received had a wrong assumption and did not fix the problem). Philosophically, I guess the purpose of the controller spec is to test that the controller does the things that it is supposed to do, which DOES NOT include default behavior of the Rails/Rack stack. And I guess that request specs are intended to test the operation of the entire system across a given request (or multiple requests that interact). So it makes sense that I should only test things that the controller does, not that it assumes are done for it, in controller specs.
As you can tell, I’m still trying to get my head around exactly what should be tested where. That seems to be at the same time, the single most important concept to understand, and the one with the most subtleties to it.
I just took a break in writing this email and started reading about the whole controller tests vs. request tests issue. I’m convinced that request specs are the way to go. So here is my follow-up question: I’m bringing up-to-date a project that was running in Rails 3.1/Rspec2 to more recent and supported versions of those two products. I can see that I’m going to need to replace my controller specs with request specs at some point. The question is when to do it. Right now, I’ve upgraded to Rspec 2.99 and filling in all the missing tests before moving on to a later Rails/RSpec version (per previous recommendations from this list). Is this the time to convert my controller specs into request specs, or are there important features missing from request specs in 2.99 such that I should wait until a later version of Rspec to do that?