Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Thor::CoreExt::HashWithIndifferentAccess#slice method #812

Merged
merged 3 commits into from
May 15, 2023
Merged
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
Next Next commit
Specs for HashWithIndifferentAccess#slice
  • Loading branch information
shuuuuun authored and rafaelfranca committed May 15, 2023
commit b7a672bac0c4b92e4c74a5714473ecfbf70abf54
14 changes: 14 additions & 0 deletions spec/core_ext/hash_with_indifferent_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
expect(@hash.fetch(:missing, :found)).to eq(:found)
end

it "supports slice" do
expect(@hash.slice("foo")).to eq({"foo" => "bar"})
expect(@hash.slice(:foo)).to eq({"foo" => "bar"})

expect(@hash.slice("baz")).to eq({"baz" => "bee"})
expect(@hash.slice(:baz)).to eq({"baz" => "bee"})

expect(@hash.slice("foo", "baz")).to eq({"foo" => "bar", "baz" => "bee"})
expect(@hash.slice(:foo, :baz)).to eq({"foo" => "bar", "baz" => "bee"})

expect(@hash.slice("missing")).to eq({})
expect(@hash.slice(:missing)).to eq({})
end

it "has key checkable by either strings or symbols" do
expect(@hash.key?("foo")).to be true
expect(@hash.key?(:foo)).to be true
Expand Down