Rails newbはこちら。
インデックス ルートの 200 ステータス コードを RSpec テストしようとしています。
私のindex_controller_spec.rb で:
require 'spec_helper'
describe IndexController do
it "should return a 200 status code" do
get root_path
response.status.should be(200)
end
end
ルート.rb:
Tat::Application.routes.draw do
root to: "index#page"
end
インデックスコントローラー:
class IndexController < ApplicationController
def page
end
end
ブラウザでアクセスするとすべて問題ありませんが、RSpec コマンドラインでエラーが発生します。
IndexController should return a 200 status code
Failure/Error: get '/'
ActionController::RoutingError:
No route matches {:controller=>"index", :action=>"/"}
# ./spec/controllers/index_controller_spec.rb:6:in `block (2 levels) in <top (required)>
'
理解できない?!
ありがとう。