aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/matchers/have_rows.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/matchers/have_rows.rb')
-rw-r--r--spec/support/matchers/have_rows.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/matchers/have_rows.rb b/spec/support/matchers/have_rows.rb
new file mode 100644
index 0000000000..7d9c6a20c9
--- /dev/null
+++ b/spec/support/matchers/have_rows.rb
@@ -0,0 +1,18 @@
+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 \ No newline at end of file