0
0
Fork 0

* fixed a small bug with ruby 1.9.2 and #<=>

* this method is implemented for every object, so another check is
  needed
This commit is contained in:
Gibheer 2011-06-16 13:16:56 +02:00
parent f0dbb9e39f
commit 61b962fea3
4 changed files with 6 additions and 5 deletions

View File

@ -46,7 +46,9 @@ module Polecat
end
def check_key key
raise ArgumentError, 'key does not support #<=>' unless key.respond_to?(:<=>)
unless key.respond_to?(:<=>) && key.respond_to?(:<=)
raise ArgumentError, 'key does not support #<=>'
end
end
private :check_key
end

View File

@ -17,7 +17,6 @@ describe "HashStorage#add" do
end
it "raises an error when the attribute does not support #<=>" do
s.add('foo', 'bar')
lambda { s.add(:foo, 'baz') }.should raise_error(ArgumentError)
lambda { s.add(nil, 'baz') }.should raise_error(ArgumentError)
end
end

View File

@ -22,6 +22,6 @@ describe "HashStorage#delete" do
end
it "raises an error when the argument does not support #<=>" do
lambda { s.delete(:foo) }.should raise_error(ArgumentError)
lambda { s.delete(nil) }.should raise_error(ArgumentError)
end
end

View File

@ -19,6 +19,6 @@ describe "HashStorage#find" do
end
it "raises an error when the type does not know #<=>" do
lambda { s.find(:foo) }.should raise_error(ArgumentError)
lambda { s.find(nil) }.should raise_error(ArgumentError)
end
end