summaryrefslogtreecommitdiff
path: root/spec/ruby/core/hash/except_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/hash/except_spec.rb')
-rw-r--r--spec/ruby/core/hash/except_spec.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/spec/ruby/core/hash/except_spec.rb b/spec/ruby/core/hash/except_spec.rb
index ac84f9975c..77a020e9b7 100644
--- a/spec/ruby/core/hash/except_spec.rb
+++ b/spec/ruby/core/hash/except_spec.rb
@@ -7,7 +7,7 @@ describe "Hash#except" do
it "returns a new duplicate hash without arguments" do
ret = @hash.except
- ret.should_not equal(@hash)
+ ret.should_not.equal?(@hash)
ret.should == @hash
end
@@ -19,14 +19,24 @@ describe "Hash#except" do
@hash.except(:a, :chunky_bacon).should == { b: 2, c: 3 }
end
- it "always returns a Hash without a default" do
- klass = Class.new(Hash)
- h = klass.new(:default)
- h[:bar] = 12
- h[:foo] = 42
- r = h.except(:foo)
- r.should == {bar: 12}
- r.class.should == Hash
- r.default.should == nil
+ it "does not retain the default value" do
+ h = Hash.new(1)
+ h.except(:a).default.should == nil
+ h[:a] = 1
+ h.except(:a).default.should == nil
+ end
+
+ it "does not retain the default_proc" do
+ pr = proc { |h, k| h[k] = [] }
+ h = Hash.new(&pr)
+ h.except(:a).default_proc.should == nil
+ h[:a] = 1
+ h.except(:a).default_proc.should == nil
+ end
+
+ it "retains compare_by_identity flag" do
+ h = { a: 9, c: 4 }.compare_by_identity
+ h2 = h.except(:a)
+ h2.compare_by_identity?.should == true
end
end