I feel like I have everything I need in my routes.rb, my controller, and my controller spec, but for some reason I'm still getting a routing error (ActionController::RoutingError). Here's my controller:
class HunchController < ActionController::Base
protect_from_forgery
def results
auth_token_key = params[:auth_token_key]
user_id = params[:user_id]
@user = User.create!
@user.auth_token = @user.get_auth_token(auth_token_key, user_id)
@recommended_books = @user.get_recommended_books(@user.auth_token)
end
end
Here's my controller spec:
require 'spec_helper'
describe HunchController do
describe "POST 'results'" do
before do
@params = {
:auth_token_key => "my auth token",
:user_id => "my user id"
}
end
it "succeeds" do
post :results, @params
response.should be_success
end
end
end
And here's my routes.rb:
MyApplicationName::Application.routes.draw do
root :to => 'hunch#index'
resources :users
post 'hunch/results' => "hunch#results"
match '/results' => 'hunch#results'
end
EDIT: Here's my rake routes output:
root / {:controller=>"pages", :action=>"index"}
hunch_results POST /hunch/results(.:format) {:controller=>"hunch", :action=>"results"}
results /results(.:format) {:controller=>"hunch", :action=>"results"}
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
EDIT #2: I'm getting this error with my users#show test too. Here's the actual error:
1) UsersController#show succeeds
Failure/Error: get :show
ActionController::RoutingError:
No route matches {:controller=>"users", :action=>"show"}
# ./spec/controllers/users_controller_spec.rb:13:in `block (3 levels) in <top (required)>'
UsersController
spec, not theHunchController
spec. – Andrew Marshall