Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rake/task_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def fetch(*args, &block)
end

def deconstruct_keys(keys)
@hash.slice(*keys)
keys ? @hash.slice(*keys) : to_hash
end

protected
Expand Down
1 change: 1 addition & 0 deletions test/test_rake_task_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_deconstruct_keys
omit "No stable pattern matching until Ruby 3.1 (testing #{RUBY_VERSION})" if RUBY_VERSION < "3.1"

ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
assert_equal ta.deconstruct_keys(nil), { a: 1, b: 2, c: 3 }
assert_equal ta.deconstruct_keys([:a, :b]), { a: 1, b: 2 }

@rgarner rgarner Jun 2, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_equal ta.deconstruct_keys(nil), { a: 1, b: 2, c: 3 }
assert_equal ta.deconstruct_keys([:a, :b]), { a: 1, b: 2 }
assert_equal({ a: 1, b: 2, c: 3 }, ta.deconstruct_keys(nil))
assert_equal({ a: 1, b: 2 }, ta.deconstruct_keys([:a, :b]))

Being an RSpec devotee, I spoke with an accent when I added this test and had the assert_equal(expected, actual) order backwards. It'd only affect the failure message but I'd hate for someone plugging a hole to copy my bad accent...

(I went to fix it but then noticed you'd opened this PR! Too quick for me 😉)

@nevans nevans Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also an rspec guy, so I get the order of these backwards pretty often myself. I certainly didn't notice they were in the wrong order here! 😉 Anyway, I pushed an update with them in the correct order. Thanks. 🙂

end

Expand Down