Note that there are some explanatory texts on larger screens.

plurals
  1. PORouting Error when running controller spec (rspec)
    primarykey
    data
    text
    <p>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:</p> <pre><code>class HunchController &lt; 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 </code></pre> <p>Here's my controller spec:</p> <pre><code>require 'spec_helper' describe HunchController do describe "POST 'results'" do before do @params = { :auth_token_key =&gt; "my auth token", :user_id =&gt; "my user id" } end it "succeeds" do post :results, @params response.should be_success end end end </code></pre> <p>And here's my routes.rb:</p> <pre><code>MyApplicationName::Application.routes.draw do root :to =&gt; 'hunch#index' resources :users post 'hunch/results' =&gt; "hunch#results" match '/results' =&gt; 'hunch#results' end </code></pre> <hr> <p>EDIT: Here's my rake routes output:</p> <pre><code> root / {:controller=&gt;"pages", :action=&gt;"index"} hunch_results POST /hunch/results(.:format) {:controller=&gt;"hunch", :action=&gt;"results"} results /results(.:format) {:controller=&gt;"hunch", :action=&gt;"results"} users GET /users(.:format) {:action=&gt;"index", :controller=&gt;"users"} POST /users(.:format) {:action=&gt;"create", :controller=&gt;"users"} new_user GET /users/new(.:format) {:action=&gt;"new", :controller=&gt;"users"} edit_user GET /users/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"users"} user GET /users/:id(.:format) {:action=&gt;"show", :controller=&gt;"users"} PUT /users/:id(.:format) {:action=&gt;"update", :controller=&gt;"users"} </code></pre> <hr> <p>EDIT #2: I'm getting this error with my users#show test too. Here's the actual error:</p> <pre><code> 1) UsersController#show succeeds Failure/Error: get :show ActionController::RoutingError: No route matches {:controller=&gt;"users", :action=&gt;"show"} # ./spec/controllers/users_controller_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload