ブラウザー経由でコントローラー ルートを正常にロードできるにもかかわらず、コントローラー ルートのテストでエラーが発生します。Rails4 + rspec.
何か案は?
#controller spec
describe PublicSitesController do
describe "GET index" do
it "returns success" do
get :index #line 7 in the spec file
response.status.should == 200
end
end
end
#routes
get ":site_name/:page_name", to: "public_sites#show"
get ":site_name", to: 'public_sites#index'
get "/", to: 'public_sites#root'
#controller
class PublicSitesController < ApplicationController
def root
end
def index
end
def show
end
end
#the error:
Failures:
1) PublicSitesController GET index returns success
Failure/Error: get :index
ActionController::UrlGenerationError:
No route matches {:action=>"index", :controller=>"public_sites"}
# ./spec/controllers/public_sites_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
以下は、rake ルート経由の関連ルートです。
GET /:site_name/:page_name(.:format) public_sites#show
POST /:site_name/:page_name(.:format) public_sites#receive_form
GET /:site_name(.:format) public_sites#index
GET / public_sites#root