features/steps/ruby_notifier_steps.rb in bugsnag-6.12.2 vs features/steps/ruby_notifier_steps.rb in bugsnag-6.13.0
- old
+ new
@@ -1,31 +1,75 @@
-When("I set environment variable {string} to the current IP") do |env_var|
+Then(/^the "(.+)" of the top non-bugsnag stackframe equals (\d+|".+")$/) do |element, value|
+ stacktrace = read_key_path(Server.current_request[:body], 'events.0.exceptions.0.stacktrace')
+ frame_index = stacktrace.find_index { |frame| ! /.*lib\/bugsnag.*\.rb/.match(frame["file"]) }
steps %Q{
- When I set environment variable "#{env_var}" to "#{current_ip}"
+ the "#{element}" of stack frame #{frame_index} equals #{value}
}
end
-When("I set environment variable {string} to the mock API port") do |env_var|
+Then(/^the total sessionStarted count equals (\d+)$/) do |value|
+ session_counts = read_key_path(Server.current_request[:body], "sessionCounts")
+ total_count = session_counts.inject(0) { |count, session| count += session["sessionsStarted"] }
+ assert_equal(value, total_count)
+end
+
+
+# Due to an ongoing discussion on whether the `payload_version` needs to be present within the headers
+# and body of the payload, this step is a local replacement for the similar step present in the main
+# maze-runner library. Once the discussion is resolved this step should be removed and replaced in scenarios
+# with the main library version.
+Then("the request is valid for the error reporting API version {string} for the {string}") do |payload_version, notifier_name|
steps %Q{
- When I set environment variable "#{env_var}" to "#{MOCK_API_PORT}"
+ Then the "Bugsnag-Api-Key" header equals "#{$api_key}"
+ And the payload field "apiKey" equals "#{$api_key}"
+ And the "Bugsnag-Payload-Version" header equals "#{payload_version}"
+ And the "Content-Type" header equals "application/json"
+ And the "Bugsnag-Sent-At" header is a timestamp
+
+ And the payload field "notifier.name" equals "#{notifier_name}"
+ And the payload field "notifier.url" is not null
+ And the payload field "notifier.version" is not null
+ And the payload field "events" is a non-empty array
+
+ And each element in payload field "events" has "severity"
+ And each element in payload field "events" has "severityReason.type"
+ And each element in payload field "events" has "unhandled"
+ And each element in payload field "events" has "exceptions"
}
end
-When("I set environment variable {string} to the proxy settings with credentials {string}") do |env_var, credentials|
+Given("I start the rails service") do
+ rails_version = ENV["RAILS_VERSION"]
steps %Q{
- When I set environment variable "#{env_var}" to "#{credentials}@#{current_ip}:#{MOCK_API_PORT}"
+ When I start the service "rails#{rails_version}"
+ And I wait for the host "rails#{rails_version}" to open port "3000"
}
end
-Then(/^the "(.+)" of the top non-bugsnag stackframe equals (\d+|".+")(?: for request (\d+))?$/) do |element, value, request_index|
- stacktrace = read_key_path(find_request(request_index)[:body], 'events.0.exceptions.0.stacktrace')
- frame_index = stacktrace.find_index { |frame| ! /.*lib\/bugsnag.*\.rb/.match(frame["file"]) }
+When("I navigate to the route {string} on the rails app") do |route|
+ rails_version = ENV["RAILS_VERSION"]
steps %Q{
- the "#{element}" of stack frame #{frame_index} equals #{value}
+ When I open the URL "http://rails#{rails_version}:3000#{route}"
}
end
-Then(/^the total sessionStarted count equals (\d+)(?: for request (\d+))?$/) do |value, request_index|
- session_counts = read_key_path(find_request(request_index)[:body], "sessionCounts")
- total_count = session_counts.inject(0) { |count, session| count += session["sessionsStarted"] }
- assert_equal(value, total_count)
-end
\ No newline at end of file
+Then("the payload field {string} matches the appropriate Sidekiq handled payload") do |field|
+ if ENV["SIDEKIQ_VERSION"] == "~> 2"
+ created_at_present = "false"
+ else
+ created_at_present = "true"
+ end
+ steps %Q{
+ And the payload field "#{field}" matches the JSON fixture in "features/fixtures/sidekiq/payloads/handled_metadata_ca_#{created_at_present}.json"
+ }
+end
+
+Then("the payload field {string} matches the appropriate Sidekiq unhandled payload") do |field|
+ if ENV["SIDEKIQ_VERSION"] == "~> 2"
+ created_at_present = "false"
+ else
+ created_at_present = "true"
+ end
+ steps %Q{
+ And the payload field "#{field}" matches the JSON fixture in "features/fixtures/sidekiq/payloads/unhandled_metadata_ca_#{created_at_present}.json"
+ }
+end