diff options
author | Daniel Doubrovkine (dB.) <dblock@dblock.org> | 2021-11-08 03:20:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 03:20:14 +0000 |
commit | 796f9446fe3313685fe1a5c74052e1e942d170a2 (patch) | |
tree | 893d8fab82017f8e3ea7e8d9903a069935b03770 /spec/hashie | |
parent | e9c577161b09bb1915c55a9045cbcc1435cb69a8 (diff) | |
parent | 9ba96e03a8b5baa098c7ac6841e4c021b02f1910 (diff) | |
download | hashie-796f9446fe3313685fe1a5c74052e1e942d170a2.tar.gz |
Merge pull request #545 from jackjennings/master
Add #except under Ruby 3
Diffstat (limited to 'spec/hashie')
-rw-r--r-- | spec/hashie/extensions/indifferent_access_spec.rb | 12 | ||||
-rw-r--r-- | spec/hashie/mash_spec.rb | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/spec/hashie/extensions/indifferent_access_spec.rb b/spec/hashie/extensions/indifferent_access_spec.rb index 0aec787..27585f1 100644 --- a/spec/hashie/extensions/indifferent_access_spec.rb +++ b/spec/hashie/extensions/indifferent_access_spec.rb @@ -357,6 +357,18 @@ describe Hashie::Extensions::IndifferentAccess do end end end + + with_minimum_ruby('3.0.0') do + describe '#except' do + let(:h) { subject.build(foo: 'bar', baz: 'qux') } + + it 'indifferently excepts keys from the hash' do + sliced_h = { 'baz' => 'qux' } + expect(h.except('foo')).to eq sliced_h + expect(h.except(:foo)).to eq sliced_h + end + end + end end describe 'with merge initializer' do diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb index 4731985..84a28ea 100644 --- a/spec/hashie/mash_spec.rb +++ b/spec/hashie/mash_spec.rb @@ -1097,4 +1097,17 @@ describe Hashie::Mash do end end end + + with_minimum_ruby('3.0.0') do + context '#except' do + subject(:mash) { described_class.new(a: 'A', b: 'B') } + it 'return a Hashie::Mash' do + expect(mash.except(:b)).to be_kind_of(described_class) + end + + it 'excludes keys' do + expect(mash.except(:b)).to eq('a' => 'A') + end + end + end end |