索引页面的rspec2路由错误[Rails3,Rspec2]

时间:2012-12-17 21:44:17

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

我有以下资源(config / routes.rb)

resources :dashboard

dashboard_index GET    /dashboard(.:format)           dashboard#index
                         POST   /dashboard(.:format)           dashboard#create
           new_dashboard GET    /dashboard/new(.:format)       dashboard#new
          edit_dashboard GET    /dashboard/:id/edit(.:format)  dashboard#edit
               dashboard GET    /dashboard/:id(.:format)       dashboard#show
                         PUT    /dashboard/:id(.:format)       dashboard#update
                         DELETE /dashboard/:id(.:format)       dashboard#destroy

我有以下控制器规范

require 'spec_helper'

describe DashboardController do

  describe "GET 'index'" do
    it "returns http success" do
      get :index
      response.should be_success
    end
  end

end

当我运行规范时,我会继续收到以下错误

Failures:

  1) DashboardController GET 'index' returns http success
     Failure/Error: get :index
     ActionController::RoutingError:
       No route matches {:controller=>"dashboard"}
     # ./spec/controllers/dashboard_controller_spec.rb:7:in `block (3 levels) in <top (required)>'

Finished in 0.12126 seconds

当我检查类似的问题时,几乎所有这些都是因为没有传递必需的参数,但在我的情况下我的动作不期望参数,所以这里缺少的部分

我在

gem 'rails', '3.2.9'
group :test, :development do
  gem "rspec-rails", "~> 2.0"
end

提前致谢

1 个答案:

答案 0 :(得分:0)

<@>正如@John Naegle所指出的那样,我的spork + guard设置似乎有问题而且它没有拿起'routes.rb'文件

对不起有困惑