Add debug hook and other small changes

This commit is contained in:
Justin Edmund 2025-02-11 03:08:46 -08:00
parent 7b3d353e19
commit e459d192ce
3 changed files with 18 additions and 1 deletions

View file

@ -1,5 +1,4 @@
# frozen_string_literal: true
# spec/factories/grid_summons.rb
FactoryBot.define do
factory :grid_summon do

View file

@ -366,4 +366,21 @@ RSpec.describe 'GridSummons API', type: :request do
end
end
end
# Debug hook: if any example fails and a response exists, print the error message.
after(:each) do |example|
if example.exception && defined?(response) && response.present?
error_message = begin
JSON.parse(response.body)['exception']
rescue JSON::ParserError
response.body
end
puts "\nDEBUG: Error Message for '#{example.full_description}': #{error_message}"
# Parse once and grab the trace safely
parsed_body = JSON.parse(response.body)
trace = parsed_body.dig('traces', 'Application Trace')
ap trace if trace # Only print if trace is not nil
end
end
end

View file

@ -354,6 +354,7 @@ RSpec.describe 'GridWeapons API', type: :request do
response.body
end
puts "\nDEBUG: Error Message for '#{example.full_description}': #{error_message}"
# Parse once and grab the trace safely
parsed_body = JSON.parse(response.body)
trace = parsed_body.dig('traces', 'Application Trace')