From 6ca93d638c526abe3ee90bc1a1c19c5aac5212bc Mon Sep 17 00:00:00 2001 From: Joseph Southan Date: Wed, 15 Jan 2025 12:10:11 +0000 Subject: [PATCH] Fix old hash syntax --- lib/coach/rspec.rb | 4 +++- spec/lib/coach/handler_spec.rb | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/coach/rspec.rb b/lib/coach/rspec.rb index d65a535..3c79a03 100644 --- a/lib/coach/rspec.rb +++ b/lib/coach/rspec.rb @@ -17,7 +17,9 @@ def call config[:callback].call if config.include?(:callback) log_metadata(**{ name.to_sym => true }) - response = [name + config.except(:callback).inspect.to_s] + # Emulate newer hash syntax for older Ruby versions + hash_response = config.except(:callback).map { |k, v| "#{k}: #{v}" }.join(", ") + response = [name + "{#{hash_response}}"] # Build up a list of middleware called, in the order they were called if next_middleware diff --git a/spec/lib/coach/handler_spec.rb b/spec/lib/coach/handler_spec.rb index 8fbba0c..2ad48e4 100644 --- a/spec/lib/coach/handler_spec.rb +++ b/spec/lib/coach/handler_spec.rb @@ -32,7 +32,7 @@ expect(a_double).to receive(:call) expect(b_double).to receive(:call) result = handler.call({}) - expect(result).to eq(%w[A{} B{} Terminal{:handler=>true}]) + expect(result).to eq(["A{}", "B{}", "Terminal{handler: true}"]) end context "with an invalid chain" do @@ -66,7 +66,7 @@ result = handler.call({}) - expect(result).to eq(%w[A{} B{} Terminal{:handler=>true}]) + expect(result).to eq(["A{}", "B{}", "Terminal{handler: true}"]) end context "with an invalid chain" do @@ -215,7 +215,7 @@ it "sets up the chain correctly, calling each item in the correct order" do expect(handler.build_request_chain(sequence, {}).call). - to eq(%w[A{} B{:b=>true} Terminal{}]) + to eq(["A{}", "B{b: true}", "Terminal{}"]) end context "with inheriting config" do @@ -226,7 +226,7 @@ it "calls lambda with parent middlewares config" do expect(handler.build_request_chain(sequence, {}).call). - to eq(%w[A{} C{:b=>true} D{} B{:b=>true} Terminal{}]) + to eq(["A{}", "C{b: true}", "D{}", "B{b: true}", "Terminal{}"]) end end end