You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was building a pinglish check, and wanted to include more application logic, but was worried about including it in config/application.rb. I figured out a way to include this in app/middleware as it's own class, as well as a way to test it.
Here's the example:
# app/middleware/fancy_pinglish.rbclassFancyPinglish < Pinglishdefinitialize(app,options=nil, &block)supercheck:fancydo# logic hereendcheck:exquisitedo# logic hereendcheck:epicdo# logicendendend# config/application.rbconfig.middleware.use"FancyPinglish",max: 15,path: '/_ping/fancy'# spec/middleware/fancy_pinglish_spec.rbdescribeFancyPinglish,type: :requestdocontext"when all is clear"dobeforedo# stub logicendit"returns 200"doget"/_ping/fancy"expect(response.status).toeq(200)endendcontext"when pagerduty is failing"dobeforedo# stub logicendit"returns 503"doget"/_ping/fancy"expect(response.status).toeq(503)endend# other variations hereend
The text was updated successfully, but these errors were encountered:
I was building a pinglish check, and wanted to include more application logic, but was worried about including it in
config/application.rb
. I figured out a way to include this inapp/middleware
as it's own class, as well as a way to test it.Here's the example:
The text was updated successfully, but these errors were encountered: