So I have decided to investigate the state of Rails' testing. After reading a few accepted answers here on SO talking about how Rails' testing documentation is atrocious I am starting to agree. Thus far, I am apparently not in the club of people that understand Rails testing- even though I understand the framework quite well, or so I thought.
I've read that Shoulda is a good plugin to use so I'm using it. My first test: "ensure method requires an ID parameter"... um sure this makes sense; I want to make sure that my before_filter :validate_id on my controller actually works. This is step 1 of the 3 required to test that my index's GET works the way it is supposed to. FAIL! Clearly the test environment runs differently than the normal Rails stack:
...
lib/action_controller/base.rb:524:in `process_without_filters'
...
checking everywhere I can results in practically no information on including filters when ActionController::TestCase uses get {}. Where do I join "the club of Rails testers" so I can figure this out?
context "GET :index requires id" do
setup {
get :index
}
should_redirect_to('/') { }
end