diff --git a/lib/shoulda/context/assertions.rb b/lib/shoulda/context/assertions.rb index 19356f6d..bc795f88 100644 --- a/lib/shoulda/context/assertions.rb +++ b/lib/shoulda/context/assertions.rb @@ -22,7 +22,7 @@ def assert_same_elements(a1, a2, msg = nil) # assert_contains(['a', '1'], 'a') => passes # assert_contains(['a', '1'], /not there/) => fails def assert_contains(collection, x, extra_msg = "") - collection = [collection] unless collection.is_a?(Array) + collection = Array(collection) msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}" case x when Regexp @@ -35,7 +35,7 @@ def assert_contains(collection, x, extra_msg = "") # Asserts that the given collection does not contain item x. If x is a regular expression, ensure that # none of the elements from the collection match x. def assert_does_not_contain(collection, x, extra_msg = "") - collection = [collection] unless collection.is_a?(Array) + collection = Array(collection) msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg case x when Regexp