diff --git a/lib/honeybadger/agent.rb b/lib/honeybadger/agent.rb index fd2e08cf..7281585d 100644 --- a/lib/honeybadger/agent.rb +++ b/lib/honeybadger/agent.rb @@ -119,9 +119,8 @@ def initialize(opts = {}) # # @return [String] UUID reference to the notice within Honeybadger. # @return [false] when ignored. - def notify(exception_or_opts = nil, opts = {}, **kwargs) + def notify(exception_or_opts = nil, **opts) opts = opts.dup - opts.merge!(kwargs) if exception_or_opts.is_a?(Exception) already_reported_notice_id = exception_or_opts.instance_variable_get(:@__hb_notice_id) diff --git a/lib/honeybadger/singleton.rb b/lib/honeybadger/singleton.rb index dc4f0161..3b920ae1 100644 --- a/lib/honeybadger/singleton.rb +++ b/lib/honeybadger/singleton.rb @@ -51,10 +51,10 @@ module Honeybadger # @!method notify(...) # Forwards to {Agent.instance}. # @see Agent#notify - def notify(exception_or_opts=nil, opts = {}, **kwargs) + def notify(exception_or_opts = nil, **opts) # Note this is defined directly (instead of via forwardable) so that # generated stack traces work as expected. - Agent.instance.notify(exception_or_opts, opts, **kwargs) + Agent.instance.notify(exception_or_opts, **opts) end # @api private diff --git a/spec/unit/honeybadger/agent_spec.rb b/spec/unit/honeybadger/agent_spec.rb index 6f78f29c..935a90d4 100644 --- a/spec/unit/honeybadger/agent_spec.rb +++ b/spec/unit/honeybadger/agent_spec.rb @@ -102,26 +102,15 @@ opts = {error_message: 'test'} prev = opts.dup instance = described_class.new(Honeybadger::Config.new(api_key: "fake api key", logger: NULL_LOGGER)) - instance.notify('test', opts) + instance.notify('test', **opts) expect(prev).to eq(opts) end - it "does take keyword arguments" do - opts = {error_message: 'test'} - config = Honeybadger::Config.new(api_key:'fake api key', logger: NULL_LOGGER) - instance = described_class.new(config) - - expect(instance.worker).to receive(:push) do |notice| - expect(notice.error_message).to match('test') - end - instance.notify(**opts) - end - - it "does take keyword arguments as second argument" do + it "accepts keyword arguments as second argument" do opts = {tags: 'testing, kwargs'} config = Honeybadger::Config.new(api_key:'fake api key', logger: NULL_LOGGER) instance = described_class.new(config) - + expect(instance.worker).to receive(:push) do |notice| expect(notice.error_message).to match('test') expect(notice.tags).to eq(['testing', 'kwargs']) @@ -129,18 +118,6 @@ instance.notify('test', **opts) end - it "does take explicit hash as second argument" do - opts = {tags: 'testing, hash'} - config = Honeybadger::Config.new(api_key:'fake api key', logger: NULL_LOGGER) - instance = described_class.new(config) - - expect(instance.worker).to receive(:push) do |notice| - expect(notice.error_message).to match('test') - expect(notice.tags).to eq(['testing', 'hash']) - end - instance.notify('test', opts) - end - it "does not report an already reported exception" do instance = described_class.new(Honeybadger::Config.new(api_key: "fake api key", logger: NULL_LOGGER)) exception = RuntimeError.new diff --git a/spec/unit/honeybadger_spec.rb b/spec/unit/honeybadger_spec.rb index 996103f6..96f462f7 100644 --- a/spec/unit/honeybadger_spec.rb +++ b/spec/unit/honeybadger_spec.rb @@ -102,7 +102,7 @@ Honeybadger.notify(error_message: 'uh oh') end - it "creates and sends a notice for an exception and hash" do + it "creates and sends a notice for an exception with additional arguments" do exception = build_exception notice = stub_notice!(config) notice_args = { error_message: 'uh oh' } @@ -110,7 +110,7 @@ expect(Honeybadger::Notice).to receive(:new).with(config, hash_including(notice_args.merge(exception: exception))).and_return(notice) expect(worker).to receive(:push).with(notice) - Honeybadger.notify(exception, notice_args) + Honeybadger.notify(exception, **notice_args) end it "sends a notice with a string" do