Skip to content

Commit

Permalink
wip - add a spec for failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Oct 10, 2024
1 parent 2d0eced commit c3ad3fb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sentry-ruby/spec/sentry/rspec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

Sentry.capture_exception(exception)

expect(sentry_events).not_to include_sentry_event(exception: RuntimeError, message: "Oops!")
expect(sentry_events).not_to include_sentry_event(exception: StandardError, message: "Gaah!")
end

it "matches events with context" do
Expand Down Expand Up @@ -106,5 +106,18 @@
context: { "rails.error" => { some: "stuff" } }
)
end

it "produces a useful failure message" do
Sentry.capture_message("Actual message")

expect {
expect(sentry_events).to include_sentry_event("Expected message")
}.to raise_error(RSpec::Expectations::ExpectationNotMetError) do |error|
expect(error.message).to include("Failed to find event matching:")
expect(error.message).to include("message: \"Expected message\"")
expect(error.message).to include("Captured events:")
expect(error.message).to include("\"message\": \"Actual message\"")
end
end
end
end

0 comments on commit c3ad3fb

Please sign in to comment.