Skip to content

Commit

Permalink
Fix old hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSouthan committed Jan 15, 2025
1 parent 96f7d77 commit 6ca93d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/coach/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/coach/handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6ca93d6

Please sign in to comment.