0
我正在嘗試構建正確的rspec測試以驗證我的410狀態代碼處理程序是否正在工作。以下是該航線包羅萬象的樣子:rails 4 api rspec test http status code 410
match '*not_found', to: 'error#error_404', via: :all
我簡單的錯誤控制器:
class ErrorController < ApplicationController
def error_404
head status: 410
end
end
我目前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的錯誤消息:
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)>'
關於如何獲得任何想法這個測試通過?我知道路線將不存在,但我無法嘗試使用get
使其工作...