I want to check that the application responds with 404 error and has the code:
require 'spec_helper'
describe Admin::UsersController do
describe "GET new" do
before { get :new }
it { should respond_with(404) }
end
end
My routes:
namespace :admin, module: :admin do
resources :users, except: [:new, :create]
end
When I started the local server in production mode, it really responds to 404 error, but when I run rspec test, it gives me the following:
1) Admin::UsersController GET new shold not be successful
Failure/Error: get :new
ActionController::UrlGenerationError:
No route matches {:action=>"new", :controller=>"admin/users"}
How can I check this correctly?
Updated with the correct answer:
describe "GET new" do
it "should not route to new" do
expect(get: :new).not_to be_routable
end
end
source
share