RSpec 2:带有rspec-rails的'route_to'上的NoMethodError?

时间:2011-03-09 17:44:49

标签: ruby-on-rails-3 rspec2 rspec-rails

我正在尝试运行此测试...

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

...并且它仍然失败并显示以下错误消息:

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)>'

我正在rspec-rails 2.5.0使用rails 3.0.5&amp; rspec 2.5.1

我正在按照rdocs中的说法执行我的代码,尝试跟随this example code ...我做错了什么?救命啊!

1 个答案:

答案 0 :(得分:25)

Aph,发现了我的问题。

我的路由规范文件夹名为spec/routes,而不是spec/routing,它应该是。

错过了readme