I am trying to build the correct rspec test to verify my 410 status code handler is working. Here is what the route catch all looks like:
match '*not_found', to: 'error#error_404', via: :all
My simple error controller:
class ErrorController < ApplicationController
def error_404
head status: 410
end
end
My current rspec:
require 'spec_helper'
describe ErrorController do
context "Method #error_404 handling missing routes =>" do
it "Should have the 410 status code.." do
get :error_404
expect(response.status).to be(410)
end
end
end
Rspec Error Message:
1) ErrorController Method #error_404 handling missing routes => Should have the 410 status code..
Failure/Error: get :error_404
ActionController::UrlGenerationError:
No route matches {:action=>"error_404", :controller=>"error"}
# ./spec/controllers/error_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
Any ideas on how to get this test to pass? I know the route will not exist but I am having trouble trying to use get
to make it work...