lib/chop/form.rb in chop-0.25.0 vs lib/chop/form.rb in chop-0.25.1

- old
+ new

@@ -6,10 +6,21 @@ def self.fill_in! table, session: Capybara.current_session, path: "features/support/fixtures" new(table, session, path).fill_in! end def self.diff! selector, table, session: Capybara.current_session, &block - all_fields = session.find("form").all("input, textarea, select") + 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 + + all_fields = root.all("input, textarea, select") relevant_fields = all_fields.inject([]) do |fields, field| next fields if field[:name].blank? next fields if field[:type] == "submit" next fields if field[:type] == "hidden" fields + [field]