提交 96055414 编写于 作者: M Mislav Marohnić 提交者: Pratik Naik

Ensure Hash#except is allowed on a frozen hash. References #382

Signed-off-by: NPratik Naik <pratiknaik@gmail.com>
上级 113de01e
......@@ -10,7 +10,7 @@ module Hash #:nodoc:
module Except
# Returns a new hash without the given keys.
def except(*keys)
clone.except!(*keys)
dup.except!(*keys)
end
# Replaces the hash without the given keys.
......
......@@ -341,6 +341,20 @@ def test_except
assert_equal expected, original.except!(:c)
assert_equal expected, original
end
def test_except_with_original_frozen
original = { :a => 'x', :b => 'y' }
original.freeze
assert_nothing_raised { original.except(:a) }
end
uses_mocha 'except with expectation' do
def test_except_with_mocha_expectation_on_original
original = { :a => 'x', :b => 'y' }
original.expects(:delete).never
original.except(:a)
end
end
end
class IWriteMyOwnXML
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册