[rspec-users] Functional Tests with custom routes

Paul H. lists at ruby-forum.com
Fri Mar 18 11:29:38 EDT 2011


Say I have a custom route like this...

map.connect 'item/:id/some_action', :controller => 'object', :action =>
'change_color', :conditions => {:method => :put}

I've been writing my tests like this...

describe ObjectController
   describe "PUT item/:id/some_action" do
      [...]
      put :change_color, {:id => 'blue'}
      [...]
   end
end

So the test doesn't actually test the url - "item/blue/some_action", but
rather the underlying Controller/Action that implements it.

Is there a way to write my tests "in terms of" the url - something
like...

describe ObjectController
   describe "PUT item/:id/some_action" do
      [...]
      put "item/blue/some_action"
      [...]
   end
end

Or are controller tests simply not the place to do this, and I should do
it in Cucumber or something?

Cheers

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list