Matthew Bass

Musings on software and life…

April 28th, 2009

BarCampRDU 2009 registration now open

The date and venue for BarCamp RDU 2009 have been decided upon and registration is now open. Register early to ensure you have a seat. This is the fourth year of BarCamp and it just keeps getting better every year. The variety and quality of presentations last year was incredible. The price of admission (free) is certainly nothing to balk at. I’ve really enjoyed attending in past years. This is a great learning and networking opportunity so be sure to mark your calendars for August 8th. See you there!

April 13th, 2009

rspec’s route_for breaks when upgrading Rails

Came across this interesting test failure after upgrading a project to Rails 2.2.2 earlier today:

should route users's 'destroy' action correctly

The recognized options <{"action"=>"show", "id"=>"1",
"controller"=>"users"}> did not match <{"action"=>"destroy", "id"=>"1",
"controller"=>"users"}>, difference: <{"action"=>"destroy"}>

Turns out that rspec’s route_for method behaves differently when run against Rails 2.2+ due to the routing changes. The controller in question is setup as a resource, so the “destroy” action must be called via an HTTP DELETE, not a GET.

The failing line in the test looked like this:

route_for(:controller => 'users', :action => 'destroy', :id => 1).should == '/users/1'

The fix was simple enough:

route_for(:controller => 'users', :action => 'destroy', :id => 1).should == {:path => '/users/1', :method => :delete}

Hope this helps anyone who is experiencing the same problem.

|