Rspec 没有路由匹配 [英] Rspec no route matches

查看:50
本文介绍了Rspec 没有路由匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 rspec 时遇到以下错误:

I'm getting the following error with rspec:

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

这是测试

require 'spec_helper'

describe LandingController do

  describe "landing#index" do
    it "returns http success" do
      get :index
      response.should be_success
    end
  end

end

我将它安装为 root :to =>'登陆#index'.所有其他测试都通过了,只有这个测试失败了,有人能帮我理解为什么吗?

I mounted it as root :to => 'landing#index'. All other tests are passing, only this one is failing, can someone help me to understand why?

为了完整起见,这是 rake routes

root                         /                                      landing#index
auth_google_oauth2_callback  /auth/google_oauth2/callback(.:format) sessions#create
                    signout  /signout(.:format)                     sessions#destroy
                  dashboard  /dashboard(.:format)                   dashboard#index

推荐答案

如果您使用的是 Spork,如果您更新了路由,则可能需要重新启动服务器.

If you are using Spork you may need to restart the server if you updated routes.

这篇关于Rspec 没有路由匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆