class WithForm::ScopeForm

Public Class Methods

new(scope:, page:) click to toggle source
# File lib/with_form/scope_form.rb, line 10
def initialize(scope:, page:)
  @page = page
  @scope = scope
end

Public Instance Methods

attach_file(attribute, path, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 60
def attach_file(attribute, path, **options)
  @page.attach_file label(attribute), path, **options
end
check(attribute, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 15
def check(attribute, **options)
  case attribute
  when Symbol
    value = label(attribute)
  else
    value = attribute
  end

  @page.check value, **options
end
click_button(action = nil, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 64
def click_button(action = nil, **options)
  @page.click_button submit(action), **options
end
fill_in(attribute, with:, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 37
def fill_in(attribute, with:, **options)
  @page.fill_in label(attribute), with: with, **options
end
fill_in_rich_text_area(locator = nil, with:) click to toggle source
# 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) click to toggle source
Calls superclass method WithForm::TranslationHelpers#label
# File lib/with_form/scope_form.rb, line 72
def label(attribute)
  super(@scope, attribute)
end
select(value, from:, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 52
def select(value, from:, **options)
  @page.select value, from: label(from), **options
end
submit(action = nil) click to toggle source
Calls superclass method WithForm::TranslationHelpers#submit
# File lib/with_form/scope_form.rb, line 68
def submit(action = nil)
  super(@scope, action || :submit)
end
uncheck(attribute, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 26
def uncheck(attribute, **options)
  case attribute
  when Symbol
    value = label(attribute)
  else
    value = attribute
  end

  @page.uncheck value, **options
end
unselect(value, from:, **options) click to toggle source
# File lib/with_form/scope_form.rb, line 56
def unselect(value, from:, **options)
  @page.unselect value, from: label(from), **options
end