diff --git a/spec/spectator/mocks/arguments_spec.cr b/spec/spectator/mocks/arguments_spec.cr index 20ab31b..28df101 100644 --- a/spec/spectator/mocks/arguments_spec.cr +++ b/spec/spectator/mocks/arguments_spec.cr @@ -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 diff --git a/src/spectator/mocks/arguments.cr b/src/spectator/mocks/arguments.cr index 6b531cc..9a1cd5c 100644 --- a/src/spectator/mocks/arguments.cr +++ b/src/spectator/mocks/arguments.cr @@ -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.