Skip to content

Commit ec12ac9

Browse files
authored
Merge pull request #635 from nevans/deconstruct_keys-for-nil-keys
Fix TaskArguments#deconstruct_keys with keys = nil
2 parents 4664a69 + e8c48e0 commit ec12ac9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/rake/task_arguments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def fetch(*args, &block)
9595
end
9696

9797
def deconstruct_keys(keys)
98-
@hash.slice(*keys)
98+
keys ? @hash.slice(*keys) : to_hash
9999
end
100100

101101
protected

test/test_rake_task_arguments.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def test_deconstruct_keys
5858
omit "No stable pattern matching until Ruby 3.1 (testing #{RUBY_VERSION})" if RUBY_VERSION < "3.1"
5959

6060
ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
61-
assert_equal ta.deconstruct_keys([:a, :b]), { a: 1, b: 2 }
61+
assert_equal({ a: 1, b: 2, c: 3 }, ta.deconstruct_keys(nil))
62+
assert_equal({ a: 1, b: 2 }, ta.deconstruct_keys([:a, :b]))
6263
end
6364

6465
def test_enumerable_behavior

0 commit comments

Comments
 (0)