From 5696a0c76d89d298abcd6982d9dacdc4adc907d1 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Tue, 22 Dec 2015 21:21:57 +0200 Subject: [PATCH] airbrake-ruby: fix add_filter block API Fixes #8 (add_filter throwing exception) --- lib/airbrake-ruby.rb | 4 ++-- spec/airbrake_spec.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/airbrake-ruby.rb b/lib/airbrake-ruby.rb index 5d2834a4..4c8499cb 100644 --- a/lib/airbrake-ruby.rb +++ b/lib/airbrake-ruby.rb @@ -275,9 +275,9 @@ def create_deploy(deploy_params, notifier = :default) # Calls +method+ on +notifier+ with provided +args+. # # @raise [Airbrake::Error] if none of the notifiers exist - def call_notifier(notifier, method, *args) + def call_notifier(notifier, method, *args, &block) if @notifiers.key?(notifier) - @notifiers[notifier].__send__(method, *args) + @notifiers[notifier].__send__(method, *args, &block) else raise Airbrake::Error, "the '#{notifier}' notifier isn't configured" diff --git a/spec/airbrake_spec.rb b/spec/airbrake_spec.rb index 5cef6250..c8be6c91 100644 --- a/spec/airbrake_spec.rb +++ b/spec/airbrake_spec.rb @@ -6,7 +6,7 @@ end before do - described_class.configure do |c| + @notifier = described_class.configure do |c| c.project_id = 113743 c.project_key = 'fd04e13d806a90f96614ad8e529b2822' end @@ -161,6 +161,18 @@ describe ".add_filter" do include_examples 'error handling', :add_filter + + it "adds filters with help of blocks" do + filter_chain = @notifier.instance_variable_get(:@filter_chain) + filters = filter_chain.instance_variable_get(:@filters) + + expect(filters.size).to eq(2) + + described_class.add_filter {} + + expect(filters.size).to eq(3) + expect(filters.last).to be_a(Proc) + end end describe ".whitelist_keys" do