From acacbcb892d62906fae23ea030117af3804eb91f Mon Sep 17 00:00:00 2001 From: Izuta Hiroyuki Date: Mon, 16 May 2016 23:51:49 +0900 Subject: [PATCH] Don't set if args are blank --- lib/rake/task_arguments.rb | 3 ++- test/test_rake_task_arguments.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index d86c5d11a..4eaf2f8b9 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -17,7 +17,8 @@ def initialize(names, values, parent=nil) @hash = {} @values = values names.each_with_index { |name, i| - @hash[name.to_sym] = values[i] unless values[i].nil? + next if values[i].nil? || values[i] == '' + @hash[name.to_sym] = values[i] } end diff --git a/test/test_rake_task_arguments.rb b/test/test_rake_task_arguments.rb index abd41ebea..554c13f57 100644 --- a/test/test_rake_task_arguments.rb +++ b/test/test_rake_task_arguments.rb @@ -19,6 +19,11 @@ def test_multiple_values_in_args assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash) end + def test_blank_values_in_args + ta = Rake::TaskArguments.new([:a, :b, :c], ['', :two, '']) + assert_equal({:b => :two}, ta.to_hash) + end + def test_has_key ta = Rake::TaskArguments.new([:a], [:one]) assert(ta.has_key?(:a))