10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/chop/form.rb', line 10
def self.diff! selector, table, session: Capybara.current_session, &block
root = begin
if selector.is_a?(Capybara::Node::Element)
selector
else
session.find(selector)
end
rescue Capybara::ElementNotFound
raise unless @allow_not_found
Node("")
end
actual = root.all(Field.combined_css_selector)
.filter_map { |field_element| Field.from(session, field_element) }
.select(&:should_include_in_diff?)
.uniq { |field| field.field[:name] }
.filter_map(&:to_diff_row)
block.call(actual, root) if block_given?
table.diff! actual, surplus_row: false, misplaced_col: false
end
|