Skip to content

Commit bf4318a

Browse files
committed
Hash does not respond to delete!
Also remove 2nd monkeypatch in spec_helper
1 parent a0057d0 commit bf4318a

3 files changed

Lines changed: 5 additions & 11 deletions

File tree

lib/github_api/core_ext/hash.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ def except(*items)
1111
# Similar to except but modifies self
1212
#
1313
def except!(*keys)
14-
copy = self.dup
15-
keys.each { |key| copy.delete!(key) }
16-
copy
14+
keys.each { |key| delete(key) }
15+
self
1716
end unless method_defined? :except!
1817

1918
# Returns a new hash with all the keys converted to symbols

spec/github/core_ext/hash_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
context '#except!' do
1616
it "should respond to except!" do
1717
@nested_hash.should respond_to :except!
18+
copy = @nested_hash.dup
19+
copy.except!('b', 'a')
20+
copy.should be_empty
1821
end
1922
end
2023

spec/spec_helper.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,3 @@ def reset_authentication_for(object)
9999
object.send("#{item}=", nil)
100100
end
101101
end
102-
103-
class Hash
104-
def except(*keys)
105-
cpy = self.dup
106-
keys.each { |key| cpy.delete(key) }
107-
cpy
108-
end
109-
end

0 commit comments

Comments
 (0)