From 4e7ad163714c304d6c13ec71ceb5d3976d20cf2b Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Thu, 20 Oct 2016 15:20:21 -0700 Subject: [PATCH] Represent a TaskArgument object such that it's not confused with a hash. --- lib/rake/task_arguments.rb | 8 ++++++-- test/test_rake_task_arguments.rb | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index bbadf305b..4b168f0e2 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -72,11 +72,15 @@ def to_hash end def to_s # :nodoc: - @hash.inspect + inspect end def inspect # :nodoc: - to_s + inspection = @hash.map do |k,v| + "#{k.to_s}: #{v.to_s}" + end.join(", ") + + "#<#{self.class} #{inspection}>" end # Returns true if +key+ is one of the arguments diff --git a/test/test_rake_task_arguments.rb b/test/test_rake_task_arguments.rb index 262637b3d..8fcba7424 100644 --- a/test/test_rake_task_arguments.rb +++ b/test/test_rake_task_arguments.rb @@ -39,8 +39,9 @@ def test_fetch def test_to_s ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3]) - assert_equal ta.to_hash.inspect, ta.to_s - assert_equal ta.to_hash.inspect, ta.inspect + expectation = "#" + assert_equal expectation, ta.to_s + assert_equal expectation, ta.inspect end def test_to_hash