Fix incompatibility with case format in Ruby 1.9

This commit is contained in:
Dave Thomas 2008-10-14 20:53:54 -05:00
parent f1be8d1cfd
commit 4dff6b88b4
1 changed files with 8 additions and 4 deletions

View File

@ -25,8 +25,10 @@ module ThoughtBot # :nodoc:
collection = [collection] unless collection.is_a?(Array)
msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}"
case x
when Regexp: assert(collection.detect { |e| e =~ x }, msg)
else assert(collection.include?(x), msg)
when Regexp
assert(collection.detect { |e| e =~ x }, msg)
else
assert(collection.include?(x), msg)
end
end
@ -36,8 +38,10 @@ module ThoughtBot # :nodoc:
collection = [collection] unless collection.is_a?(Array)
msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg
case x
when Regexp: assert(!collection.detect { |e| e =~ x }, msg)
else assert(!collection.include?(x), msg)
when Regexp
assert(!collection.detect { |e| e =~ x }, msg)
else
assert(!collection.include?(x), msg)
end
end
end