1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/spec/support/matchers/have_rows.rb
2010-05-26 18:15:21 -04:00

18 lines
585 B
Ruby

module Matchers
def have_rows(expected)
simple_matcher "have rows" do |given, matcher|
found, got, expected = [], [], expected.map { |r| r.tuple }
given.each do |row|
got << row.tuple
found << expected.find { |r| row.tuple == r }
end
matcher.failure_message = "Expected to get:\n" \
"#{expected.map {|r| " #{r.inspect}" }.join("\n")}\n" \
"instead, got:\n" \
"#{got.map {|r| " #{r.inspect}" }.join("\n")}"
found.compact.length == expected.length && got.compact.length == expected.length
end
end
end