diff --git a/sentry-ruby/spec/sentry/rspec/matchers_spec.rb b/sentry-ruby/spec/sentry/rspec/matchers_spec.rb index bc7329550..d6d0ee52e 100644 --- a/sentry-ruby/spec/sentry/rspec/matchers_spec.rb +++ b/sentry-ruby/spec/sentry/rspec/matchers_spec.rb @@ -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 @@ -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