Skip to content

Commit

Permalink
Assert against in-project frames only
Browse files Browse the repository at this point in the history
Ruby 3.3 adds additional frames to the top of the stacktrace so frame 0
is no longer the frame we want to assert against
  • Loading branch information
imjoehaines committed Jan 4, 2024
1 parent 5020b79 commit 164d46f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion features/fixtures/plain/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def configure_using_environment
conf.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
conf.meta_data_filters << ENV["BUGSNAG_META_DATA_FILTERS"] if ENV.include? "BUGSNAG_META_DATA_FILTERS"
conf.enabled_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE"
conf.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
conf.project_root = __dir__
conf.proxy_host = ENV["BUGSNAG_PROXY_HOST"] if ENV.include? "BUGSNAG_PROXY_HOST"
conf.proxy_password = ENV["BUGSNAG_PROXY_PASSWORD"] if ENV.include? "BUGSNAG_PROXY_PASSWORD"
conf.proxy_port = ENV["BUGSNAG_PROXY_PORT"] if ENV.include? "BUGSNAG_PROXY_PORT"
Expand Down
4 changes: 2 additions & 2 deletions features/plain_features/unhandled_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Scenario Outline: An unhandled error sends a report
And the event "severityReason.type" equals "unhandledException"
And the event "device.time" is a timestamp
And the exception "errorClass" equals "<error>"
And the "file" of stack frame 0 equals "/usr/src/app/unhandled/<file>.rb"
And the "lineNumber" of stack frame 0 equals <lineNumber>
And the "file" of the first in-project stack frame equals "/usr/src/app/unhandled/<file>.rb"
And the "lineNumber" of the first in-project stack frame equals <lineNumber>

Examples:
| file | error | lineNumber | command |
Expand Down
15 changes: 15 additions & 0 deletions features/steps/ruby_notifier_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
}
end

Then(/^the "(.+)" of the first in-project stack frame equals (\d+|".+")$"/) do |key, expected|
body = Maze::Server.errors.current[:body]
stacktrace = Maze::Helper.read_key_path(body, 'events.0.exceptions.0.stacktrace')

frame_index = stacktrace.find_index { |frame| frame["inProject"] == true }

if frame_index.nil?
raise "Unable to find an in-project stack frame in stacktrace: #{stacktrace.inspect}"
end

steps %Q{
the "#{key}" of stack frame #{frame_index} equals #{expected}
}
end

Then(/^the total sessionStarted count equals (\d+)$/) do |value|
body = Maze::Server.sessions.current[:body]
session_counts = Maze::Helper.read_key_path(body, "sessionCounts")
Expand Down

0 comments on commit 164d46f

Please sign in to comment.