summaryrefslogtreecommitdiff
path: root/spec/hashie/extensions/indifferent_access_spec.rb
diff options
context:
space:
mode:
authorJack Jennings <jack.jennings@leafly.com>2021-04-06 17:45:02 -0700
committerJack Jennings <jack.jennings@leafly.com>2021-11-02 12:57:54 -0700
commit9ba96e03a8b5baa098c7ac6841e4c021b02f1910 (patch)
tree811945a20cb508cbc6866b0dacad999c1486e7ed /spec/hashie/extensions/indifferent_access_spec.rb
parent16eb591205092dab88d87673263ddf02014a350a (diff)
downloadhashie-9ba96e03a8b5baa098c7ac6841e4c021b02f1910.tar.gz
Add #except under Ruby 3
Ruby 3 adds the Hash#except method, which should return the correct Hashie object instance when called on a Mash or object using the Hashie::Extensions::IndifferentAccess mixin.
Diffstat (limited to 'spec/hashie/extensions/indifferent_access_spec.rb')
-rw-r--r--spec/hashie/extensions/indifferent_access_spec.rb12
1 files changed, 12 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