Class: WithForm::ScopeForm
- Inherits:
-
Object
- Object
- WithForm::ScopeForm
- Includes:
- ActionView::Helpers::TranslationHelper, TranslationHelpers
- Defined in:
- lib/with_form/scope_form.rb
Instance Method Summary collapse
- #attach_file(attribute, path, **options) ⇒ Object
- #check(attribute, **options) ⇒ Object
- #click_button(action = nil, **options) ⇒ Object
- #fill_in(attribute, with:, **options) ⇒ Object
- #fill_in_rich_text_area(locator = nil, with:) ⇒ Object
-
#initialize(scope:, page:) ⇒ ScopeForm
constructor
A new instance of ScopeForm.
- #label(attribute) ⇒ Object
- #select(value, from:, **options) ⇒ Object
- #submit(action = nil) ⇒ Object
- #uncheck(attribute, **options) ⇒ Object
- #unselect(value, from:, **options) ⇒ Object
Constructor Details
#initialize(scope:, page:) ⇒ ScopeForm
Returns a new instance of ScopeForm.
10 11 12 13 |
# File 'lib/with_form/scope_form.rb', line 10 def initialize(scope:, page:) @page = page @scope = scope end |
Instance Method Details
#attach_file(attribute, path, **options) ⇒ Object
60 61 62 |
# File 'lib/with_form/scope_form.rb', line 60 def attach_file(attribute, path, **) @page.attach_file label(attribute), path, ** end |
#check(attribute, **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/with_form/scope_form.rb', line 15 def check(attribute, **) case attribute when Symbol value = label(attribute) else value = attribute end @page.check value, ** end |
#click_button(action = nil, **options) ⇒ Object
64 65 66 |
# File 'lib/with_form/scope_form.rb', line 64 def (action = nil, **) @page. submit(action), ** end |
#fill_in(attribute, with:, **options) ⇒ Object
37 38 39 |
# File 'lib/with_form/scope_form.rb', line 37 def fill_in(attribute, with:, **) @page.fill_in label(attribute), with: with, ** end |
#fill_in_rich_text_area(locator = nil, with:) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/with_form/scope_form.rb', line 41 def fill_in_rich_text_area(locator = nil, with:) fill_in_script = <<~JS this.editor.loadHTML(arguments[0]) JS @page.find(:rich_text_area, label(locator)).execute_script( fill_in_script, with.to_s, ) end |
#label(attribute) ⇒ Object
72 73 74 |
# File 'lib/with_form/scope_form.rb', line 72 def label(attribute) super(@scope, attribute) end |
#select(value, from:, **options) ⇒ Object
52 53 54 |
# File 'lib/with_form/scope_form.rb', line 52 def select(value, from:, **) @page.select value, from: label(from), ** end |
#submit(action = nil) ⇒ Object
68 69 70 |
# File 'lib/with_form/scope_form.rb', line 68 def submit(action = nil) super(@scope, action || :submit) end |
#uncheck(attribute, **options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/with_form/scope_form.rb', line 26 def uncheck(attribute, **) case attribute when Symbol value = label(attribute) else value = attribute end @page.uncheck value, ** end |
#unselect(value, from:, **options) ⇒ Object
56 57 58 |
# File 'lib/with_form/scope_form.rb', line 56 def unselect(value, from:, **) @page.unselect value, from: label(from), ** end |