Rspec no route matches

删除回忆录丶 提交于 2019-12-11 02:54:43

问题


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

This is the test

require 'spec_helper'

describe LandingController do

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

end

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?

For completeness this is the output from 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

回答1:


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




回答2:


did you try to access the root page with get '/'? should work.



来源:https://stackoverflow.com/questions/11074404/rspec-no-route-matches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!