Class: Chop::Form
- Inherits:
-
Struct
- Object
- Struct
- Chop::Form
- Defined in:
- lib/chop/form.rb
Defined Under Namespace
Classes: Checkbox, Default, Field, FieldFinder, MultipleCheckbox, MultipleFile, MultipleSelect, Radio, Select, SingleFile, Textarea, ViaJavascript
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#session ⇒ Object
Returns the value of attribute session.
-
#table ⇒ Object
Returns the value of attribute table.
Class Method Summary collapse
- .diff!(selector, table, session: Capybara.current_session, &block) ⇒ Object
- .fill_in!(table, session: Capybara.current_session, path: "features/support/fixtures") ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
5 6 7 |
# File 'lib/chop/form.rb', line 5 def path @path end |
#session ⇒ Object
Returns the value of attribute session
5 6 7 |
# File 'lib/chop/form.rb', line 5 def session @session end |
#table ⇒ Object
Returns the value of attribute table
5 6 7 |
# File 'lib/chop/form.rb', line 5 def table @table end |
Class Method Details
.diff!(selector, table, session: Capybara.current_session, &block) ⇒ Object
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: .current_session, &block root = begin if selector.is_a?(::Node::Element) selector else session.find(selector) end rescue ::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 |
.fill_in!(table, session: Capybara.current_session, path: "features/support/fixtures") ⇒ Object
6 7 8 |
# File 'lib/chop/form.rb', line 6 def self.fill_in! table, session: .current_session, path: "features/support/fixtures" new(table, session, path).fill_in! end |
Instance Method Details
#fill_in! ⇒ Object
33 34 35 36 37 |
# File 'lib/chop/form.rb', line 33 def fill_in! table.rows_hash.each do |label, value| Field.for(session, label, value, path).fill_in! end end |