require 'rails_helper' describe ChatwootExceptionTracker do it 'writes the exception to the Rails logger' do exception = StandardError.new('local failure') expect(Rails.logger).to receive(:error).with(exception) described_class.new(exception).capture_exception end it 'stays local when a Sentry DSN is present' do exception = StandardError.new('private failure') user = build(:user, email: 'person@example.invalid', name: 'Private User') account = build(:account, name: 'Private Account') with_modified_env SENTRY_DSN: 'https://sentry.invalid/project' do expect(Rails.logger).to receive(:error).with(exception) described_class.new(exception, user: user, account: account).capture_exception end end end