Skip to content

Commit

Permalink
wip - better output
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Oct 9, 2024
1 parent a5fa5f5 commit 3c66c12
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions sentry-ruby/lib/sentry/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@
@tags = tags
end

failure_message do |sentry_events|
info = ["Failed to find event matching:\n"]
info << " message: #{event_message}"
info << " context: #{context.inspect}"
info << " tags: #{tags.inspect}"
info << "\n"
info << "Captured events:\n"
info << dump_events(sentry_events)
info.join("\n")
end

define_method(:context) do
opts.fetch(:context, @context || {})
end

define_method(:tags) do
opts.fetch(:tags, @tags || {})
end

def dump_events(sentry_events)
sentry_events.map(&Kernel.method(:Hash)).map do |hash|
hash.slice(:message, :contexts, :tags, :exception)
end.map do |hash|
JSON.pretty_generate(hash)
end.join("\n\n")
end

def verify_exception(event, exception: nil, message: nil, **)
return true unless exception && message

Expand Down

0 comments on commit 3c66c12

Please sign in to comment.