mardi 11 octobre 2016

Rspec not finding routes that exists

I'm trying to write a controller test and Rspec isn't finding routes that I know exist and work fine on a development server.

In my routes I have a catch-all route that should redeirect to a generic controller if someone goes to a route that isn't predefined.

routes.rb

namespace :tools do
  match '*unmatchedpath' => "generic#show", :via => :get
end

generic_controller.rb

def show
  # do stuff
end

generic_controller_spec.rb

require 'spec_helper'

describe Tools::GenericController do

describe 'GET show' do 
  it 'does stuff' do
    get :show
  end
end

Here is the error I get from rspec when I run the test above

 1) Tools::GenericController GET show does stuff
 Failure/Error: get :show
 ActionController::RoutingError:
   No route matches {:controller=>"tools/generic", :action=>"show"}

All routes work as expected on my development server so I'm not sure why Rspec isn't finding the route.

Aucun commentaire:

Enregistrer un commentaire