rspec controller syntax
Posted by jacqui maher on November 29, 2007 at 05:26 PM
The rspec docs are great, but the example code for writing Rails controller specs is a little inconsistent.
For future reference, the ‘best way’ to specify your controller is like so:
describe Manage::ListingsController, "manage listings - for the boss" do
the old way, which you shouldn’t use, was like this:
describe "manage listings - for the boss" do
controller_name "Manage::Listings"
I ran into a problem specifying my namespaced controller the old way; controller_name calls camelize on the string you pass it after splitting it on the “::” - since we have several ListingsController classes in various namespaces, my spec was sending requests to the wrong ListingsController spec, causing all kinds of failures and sadness.
Thx to the caboose geniuses for helping me out on this one, notably court3nay