On Tue, Nov 10, 2009 at 4:44 AM, Amit Kulkarni <li...@ruby-forum.com> wrote:
> Hi all, > I am writing scenarios for testing my routes but it is giving me error > as undefined method `route_for and also for params_from. > Did i miss something which i need to add in my controller > > My code is as follows: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe HomeController, "routes" do > describe "route generation" do > it "should map { :controller => 'home', :action => 'index' } to > /home" do > route_for(:controller => 'home', :action => 'index').should == > '/home' > end > > it "should map { :controller => 'home' } RESTfully" do > params_from( :get, '/home' ).should == { :controller => 'home', > :action => 'index' } > end > end > end > route_to, route_for and params_from are all available in controller specs, which are identified by: 1. spec/controllers in their path (i.e. spec/controllers/foo_controller_spec 2. describe "route generation", :type => :controller do If neither of those cases is true, then you won't have access to the right helpers and matchers. HTH, David
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users