Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

words

  • Loading branch information...
commit a209886a3b5ba811d76119255c353c709b4de7d5 1 parent 1d41ff1
@dchelimsky authored
Showing with 6 additions and 5 deletions.
  1. +1 −0  History.rdoc
  2. +5 −5 lib/spec/matchers/match_array.rb
View
1  History.rdoc
@@ -23,6 +23,7 @@
* bug fixes
* support expectations on DelegateClass (Clifford T. Matthews). Closes #48.
+ * Fixed match_array blows up if elements can't be sorted (Jeff Dean). Closes #779.
=== Version 1.2.2 / 2009-03-22
View
10 lib/spec/matchers/match_array.rb
@@ -16,10 +16,10 @@ def matches?(actual)
end
def failure_message_for_should
- message = "expected collection contained: #{safely_sort(@expected).inspect}\n"
- message += "actual collection contained: #{safely_sort(@actual).inspect}\n"
- message += "the missing elements were: #{safely_sort(@missing_items).inspect}\n" unless @missing_items.empty?
- message += "the extra elements were: #{safely_sort(@extra_items).inspect}\n" unless @extra_items.empty?
+ message = "expected collection contained: #{safe_sort(@expected).inspect}\n"
+ message += "actual collection contained: #{safe_sort(@actual).inspect}\n"
+ message += "the missing elements were: #{safe_sort(@missing_items).inspect}\n" unless @missing_items.empty?
+ message += "the extra elements were: #{safe_sort(@extra_items).inspect}\n" unless @extra_items.empty?
message
end
@@ -33,7 +33,7 @@ def description
private
- def safely_sort(array)
+ def safe_sort(array)
array.all?{|item| item.respond_to?(:<=>)} ? array.sort : array
end
Please sign in to comment.
Something went wrong with that request. Please try again.