DEV: add extra diagnostics for intermittent test fail

DEV: add extra diagnostics for intermittent test fail

From f555582eb23ff4a0d83cc49f3b8c82feea29b4b1 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Mon, 3 Dec 2018 11:31:12 +1100
Subject: [PATCH] DEV: add extra diagnostics for intermittent test fail


diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rb
index a18c397..0e9f251 100644
--- a/spec/requests/application_controller_spec.rb
+++ b/spec/requests/application_controller_spec.rb
@@ -25,7 +25,6 @@ RSpec.describe ApplicationController do
       @old_logger = Rails.logger
       @logs = StringIO.new
       Rails.logger = Logger.new(@logs)
-      Rails.logger.level = Logger::WARN
     end
 
     after do
@@ -39,12 +38,26 @@ RSpec.describe ApplicationController do
       get "/latest.json", params: { test: bad_str }
 
       expect(response.status).to eq(400)
-      expect(@logs.string).not_to include('exception app middleware')
+
+      log = @logs.string
+
+      if (log.include? 'exception app middleware')
+        # heisentest diagnostics
+        puts
+        puts "EXTRA DIAGNOSTICS FOR INTERMITENT TEST FAIL"
+        puts log
+        puts ">> action_dispatch.exception"
+        ex = request.env['action_dispatch.exception']
+        puts ">> exception class: #{ex.class} : #{ex}"
+      end
+
+      expect(log).not_to include('exception app middleware')
 
       expect(JSON.parse(response.body)).to eq(
         "status" => 400,
         "error" => "Bad Request"
       )
+
     end
   end

GitHub

1 Like