Reputation: 96454
Why am I getting that/how can I get around it?
Code is:
class UserController < ApplicationController
def index
@users=User.all
end
end
Spec is:
require 'spec_helper'
describe UserController do
describe "GET index" do
it "assigns @users" do
user = User.create(:email => '[email protected]', :password=>'12', :password_confirmation=> '12')
get :index
assigns(:users).should eq([user])
end
it "renders the index template" do
get :index
response.should render_template("index")
end
end
end
Failures:
1) UserController GET index assigns @users
Failure/Error: get :index
ActionController::RoutingError:
No route matches {:controller=>"user"}
# ./spec/controllers/user_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
2) UserController GET index renders the index template
Failure/Error: get :index
ActionController::RoutingError:
No route matches {:controller=>"user"}
# ./spec/controllers/user_controller_spec.rb:13:in `block (3 levels) in <top (required)>'
Finished in 0.13146 seconds
2 examples, 2 failures
Routes are:
TimeTracker::Application.routes.draw do
devise_for :users
resources :users
root :to => 'users#index'
end
Upvotes: 1
Views: 523
Reputation: 7338
Your controller class name is in singular (UserController
), it should be UsersController
Upvotes: 2