Search code examples
ruby-on-rails-3rspec2rspec-rails

RSpec 2: NoMethodError on 'route_to' with rspec-rails?


I'm trying to run this test...

require 'spec_helper'

describe HomeController do

  describe 'boilerplate routes' do

    it "should route to '/about'" do
      { :get => "/about" }.should route_to(:controller => 'home', :action => 'show')
    end

  end

end

... and it keeps failing with this error message:

1) HomeController boilerplate routes should route to '/about'
Failure/Error: { :get => "/about" }.should route_to(:controller => 'home', :action => 'show')
   NoMethodError:
      undefined method `route_to' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x00000101499650>
   # ./spec/routes/home_routes_spec.rb:8:in `block (3 levels) in <top (required)>'

I'm using rspec-rails 2.5.0 with rails 3.0.5 & rspec 2.5.1.

I'm doing my code just like it says in the rdocs, trying to follow along with this example code... what am I doing wrong? Help!


Solution

  • Aph, found my problem.

    I had my routing spec folder named spec/routes instead of spec/routing, which it should be.

    Missed that in the readme.