rspec/rspec-rails — Issue #495: Weird issue with missing route in app, but no missing in spec
Author: theodorton
Created: 2012-01-24 15:27:05+00:00
State: open

Given the following three files:

````ruby
# routes.rb
MyRailsApplication::Application.routes.draw do
namespace :app do
resources :entries do
collection do
get :search
end
end
end
end
````

````ruby
# app/controllers/app/entries_controller.rb
class App::EntriesController < App::BaseController
def search ; end
end
````

````ruby
# spec/controllers/app/entries_controller_spec.rb

describe App::CompaniesController do
describe "GET search" do
it "should be successful" do
get :search
response.should be_successful
end
end

describe "POST search" do
it "should be successful" do
post 'search'
response.should be_successful
end
end
end

````

I don't get "No route matches" for the second example, as I would expect (the app throws a `No route matches [POST] "/app/entries/search"`) as "post :search" is not defined in my routes.rb file.

Shouldn't RSpec give the same results as the application when a route is missing?

I would love to fix this, but I had a hard time looking to the action controller TestCase-class and more, but couldn't pin point where this issue is based.