diff --git a/lib/raven/base.rb b/lib/raven/base.rb index 4d16393a6..391de58c2 100644 --- a/lib/raven/base.rb +++ b/lib/raven/base.rb @@ -49,9 +49,15 @@ def client end # Tell the log that the client is good to go - def report_ready - logger.info "Raven #{VERSION} ready to catch errors" + def report_status + return if client.configuration.silence_ready + if client.configuration.send_in_current_environment? + logger.info "Raven #{VERSION} ready to catch errors" + else + logger.info "Raven #{VERSION} configured not to send errors." + end end + alias_method :report_ready, :report_status # Call this method to modify defaults in your initializers. # @@ -63,7 +69,7 @@ def configure yield(configuration) if block_given? self.client = Client.new(configuration) - report_ready unless client.configuration.silence_ready + report_status self.client end diff --git a/spec/raven/raven_spec.rb b/spec/raven/raven_spec.rb index d1db866eb..0e05a3099 100644 --- a/spec/raven/raven_spec.rb +++ b/spec/raven/raven_spec.rb @@ -100,6 +100,35 @@ def ivars(object) end end + describe '.report_status' do + let(:ready_message) do + "Raven #{Raven::VERSION} ready to catch errors" + end + + let(:not_ready_message) do + "Raven #{Raven::VERSION} configured not to send errors." + end + + it 'logs a ready message when configured' do + Raven.configuration.silence_ready = false + expect(Raven.configuration).to( + receive(:send_in_current_environment?).and_return(true)) + expect(Raven.logger).to receive(:info).with(ready_message) + Raven.report_status + end + it 'logs not ready message if the config does not send in current environment' do + Raven.configuration.silence_ready = false + expect(Raven.configuration).to( + receive(:send_in_current_environment?).and_return(false)) + expect(Raven.logger).to receive(:info).with(not_ready_message) + Raven.report_status + end + it 'logs nothing if "silence_ready" configuration is true' do + Raven.configuration.silence_ready = true + expect(Raven.logger).not_to receive(:info) + Raven.report_status + end + end end