I can’t seem to work around the ‘get’ method in my rspec controller specs for my scoped routes.
I’m scoping the routes for my ‘visitor’ controllers so that they are within the ‘visitor’ module namespace, but are at the root of the routing. So ‘mysite.com/foo’ goes to the Visitor::FooController.
config/routes.rb
scope :module => 'visitor' do
resources :inquiries
end
spec/controllers/visitor/inquiries_controller_spec.rb
require 'spec_helper'
describe Visitor::InquiriesController do
describe 'GET new' do
it 'should render template visitor/inquiries/new' do
get :new
end
end
end
app/controllers/visitor/inquiries_controller.rb
class Visitor::InquiriesController < Visitor::BaseController
def new
end
end
When I run the spec I get the following error.
No route matches {:controller=>"visitor/inquiries", :action=>"new"}
I tried adding some additional parameters for get (e.g. :url => ‘inquiries/new’, :controller => ‘inquiries’) but I can’t seem to get around this issue. Hitting ‘inquiries/new’ with my browser works fine and shows that my routes are working as expected.
I’m new to rspec so there may be some fundamental issue I’m not understanding here. Otherwise I’m looking for a way to push past this issues so I can test these ‘visitor’ controllers. Any help is appreciated!
The problem was fixed when I restarted my computer the next day. There seemed to be some sort of issue with Spork that was causing the problem. I’m not sure if this question can be removed, but it probably doesn’t provide a lot of value to Stackoverflow.