Fix table row matchers

The matcher was silently failing on the check step (adding ~30 seconds to out specs each time it was used!), so I changed it to fail if the basic step does not succeed
This commit is contained in:
Rob Harrington
2018-06-02 15:53:19 +10:00
committed by luisramos0
parent 56c07aac5c
commit 3b40ede0b8

View File

@@ -3,14 +3,18 @@ RSpec::Matchers.define :have_table_row do |row|
match do |node|
@row = row
node.has_selector? "tr", text: row.join(" ").strip # Check for appearance
text_without_blanks = row.select(&:present?).join(" ").strip
return false unless node.has_selector? "tr", text: text_without_blanks # Check for appearance
rows_under(node).include? row # Robust check of columns
end
match_when_negated do |node|
@row = row
node.has_no_selector? "tr", text: row.join(" ").strip # Check for appearance
text_without_blanks = row.select(&:present?).join(" ").strip
return false unless node.has_no_selector? "tr", text: text_without_blanks # Check for appearance
!rows_under(node).include? row # Robust check of columns
end