在我的Grape / Rails应用程序中,我已经在ApplicationController
中实施了维护模式,因此当该模式处于活动状态时,它将从应用程序中的任何位置重定向到maintenance_mode_path
。如何强制rspec在一段时间内处于不同的端点。 api/v1/new_endpoint
,而整个测试都在MaintenanceModeController
中进行?
maintenance_mode_controller_spec
context 'when maintenance mode is active' do
context 'when current page is not maintenance page' do
let(:call_endpoint) { get('/api/v1/new_endpoint') }
it 'redirect to the maintenance page' do
call_endpoint
expect(response).to have_http_status(:redirect)
end
end
end
但是上面的代码有一个错误
失败/错误:let(:call_endpoint){get('/ api / v1 / bank_partners')}
actionController :: UrlGenerationError:没有路由匹配{:action =>“ / api / v1 / new_endpoint”,:controller =>“ maintenance_mode”}