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 ruby2.5 Hash#slice to Sinatra::IndifferentHash #1405

Merged
merged 2 commits into from
Apr 28, 2018
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
Prev Previous commit
Add Sinatra::IndifferentHash#slice spec
  • Loading branch information
iguchi1124 committed Feb 22, 2018
commit 23afce5269ee084c33971a319dd24c970c6a3b25
12 changes: 12 additions & 0 deletions test/indifferent_hash_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ def test_dig
assert_nil @hash.dig('nested', ?a, 0, :d)
end

def test_slice
skip_if_lacking :slice

assert_equal Sinatra::IndifferentHash[a: :a], @hash.slice(:a)
assert_equal Sinatra::IndifferentHash[b: :b], @hash.slice(?b)
assert_equal Sinatra::IndifferentHash[3 => 3], @hash.slice(3)
assert_equal Sinatra::IndifferentHash.new, @hash.slice(:d)
assert_equal Sinatra::IndifferentHash[a: :a, b: :b, 3 => 3], @hash.slice(:a, :b, 3)
assert_equal Sinatra::IndifferentHash[simple_nested: { a: :a, ?b => :b }], @hash.slice(:simple_nested)
assert_equal Sinatra::IndifferentHash[nested: { a: [{ a: :a, ?b => :b }, :c, 4], ?f => :f, 7 => 7 }], @hash.slice(:nested)
end

def test_fetch_values
skip_if_lacking :fetch_values

Expand Down