Better formatting for empty arguments

This commit is contained in:
Michael Miller 2022-03-12 17:49:07 -07:00
parent ca827a3c52
commit 5ad29f486f
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
2 changed files with 10 additions and 0 deletions

View file

@ -30,6 +30,14 @@ Spectator.describe Spectator::Arguments do
it "formats the arguments" do
is_expected.to eq("(42, \"foo\", bar: \"baz\", qux: 123)")
end
context "when empty" do
let(arguments) { Spectator::Arguments.empty }
it "returns (no args)" do
is_expected.to eq("(no args)")
end
end
end
describe "#==" do

View file

@ -29,6 +29,8 @@ module Spectator
# Constructs a string representation of the arguments.
def to_s(io : IO) : Nil
return io << "(no args)" if args.empty? && kwargs.empty?
io << '('
# Add the positional arguments.