diff --git a/sentry-ruby/spec/sentry/client_spec.rb b/sentry-ruby/spec/sentry/client_spec.rb index 56bab2e9e..88b73c7ec 100644 --- a/sentry-ruby/spec/sentry/client_spec.rb +++ b/sentry-ruby/spec/sentry/client_spec.rb @@ -1,21 +1,14 @@ # frozen_string_literal: true -class ExceptionWithContext < StandardError - def sentry_context - { - foo: "bar" - } - end -end - RSpec.describe Sentry::Client do + subject { Sentry::Client.new(configuration) } + let(:configuration) do Sentry::Configuration.new.tap do |config| config.dsn = Sentry::TestHelper::DUMMY_DSN config.transport.transport_class = Sentry::DummyTransport end end - subject { Sentry::Client.new(configuration) } let(:hub) do Sentry::Hub.new(subject, Sentry::Scope.new) @@ -571,8 +564,18 @@ module ExcTag; end end context 'when the exception responds to sentry_context' do + let(:exception_with_context) do + Class.new(StandardError) do + def sentry_context + { + foo: "bar" + } + end + end + end + let(:hash) do - event = subject.event_from_exception(ExceptionWithContext.new) + event = subject.event_from_exception(exception_with_context.new) event.to_h end