spec/rdkafka/config_spec.rb in karafka-rdkafka-0.15.0.alpha1 vs spec/rdkafka/config_spec.rb in karafka-rdkafka-0.15.0.alpha2

- old
+ new

@@ -113,9 +113,42 @@ Rdkafka::Config.error_callback = 'a string' }.to raise_error(TypeError) end end + context "oauthbearer calllback" do + context "with a proc/lambda" do + it "should set the callback" do + expect { + Rdkafka::Config.oauthbearer_token_refresh_callback = lambda do |config, client_name| + puts config + puts client_name + end + }.not_to raise_error + expect(Rdkafka::Config.oauthbearer_token_refresh_callback).to respond_to :call + end + end + + context "with a callable object" do + it "should set the callback" do + callback = Class.new do + def call(config, client_name); end + end + + expect { + Rdkafka::Config.oauthbearer_token_refresh_callback = callback.new + }.not_to raise_error + expect(Rdkafka::Config.oauthbearer_token_refresh_callback).to respond_to :call + end + end + + it "should not accept a callback that's not callable" do + expect { + Rdkafka::Config.oauthbearer_token_refresh_callback = 'not a callback' + }.to raise_error(TypeError) + end + end + context "configuration" do it "should store configuration" do config = Rdkafka::Config.new config[:"key"] = 'value' expect(config[:"key"]).to eq 'value'