Permalink
Browse files

if the sort fails, rescue and return the array as-is

- Closes #81.
- Closes #83.
  • Loading branch information...
1 parent 3d8cfc7 commit d49eba7ed785ca2856fdd1890ac10e86cc6be64b Peter van Hardenberg committed with dchelimsky Jul 30, 2011
Showing with 2 additions and 4 deletions.
  1. +1 −0 Changelog.md
  2. +1 −1 lib/rspec/matchers/match_array.rb
  3. +0 −3 spec/rspec/matchers/match_array_spec.rb
View
@@ -8,6 +8,7 @@
* Bug fixes
* Fix typo in have(n).xyz documentation (Jean Boussier)
+ * fix safe_sort for ruby 1.9.2 (Kernel now defines <=> for Object) (Peter van Hardenberg)
### 2.6.0 / 2011-05-12
@@ -34,7 +34,7 @@ def description
private
def safe_sort(array)
- array.all?{|item| item.respond_to?(:<=>)} ? array.sort : array
+ array.sort rescue array
end
def difference_between_arrays(array_1, array_2)
@@ -1,9 +1,6 @@
require 'spec_helper'
class UnsortableObject
- # ruby-1.9.2 adds <=> to Object
- undef_method :<=> rescue nil
-
def initialize(id)
@id = id
end

0 comments on commit d49eba7

Please sign in to comment.