Class: WithForm::ScopeForm

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
lib/with_form/scope_form.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope:, page:) ⇒ ScopeForm

Returns a new instance of ScopeForm.



7
8
9
10
# File 'lib/with_form/scope_form.rb', line 7

def initialize(scope:, page:)
  @page = page
  @scope = scope
end

Instance Method Details

#attach_file(attribute, path, **options) ⇒ Object



24
25
26
# File 'lib/with_form/scope_form.rb', line 24

def attach_file(attribute, path, **options)
  @page.attach_file label(attribute), path, **options
end

#click_button(action = nil, **options) ⇒ Object



28
29
30
# File 'lib/with_form/scope_form.rb', line 28

def click_button(action = nil, **options)
  @page.click_button submit(action), **options
end

#fill_in(attribute, with:, **options) ⇒ Object



12
13
14
# File 'lib/with_form/scope_form.rb', line 12

def fill_in(attribute, with:, **options)
  @page.fill_in label(attribute), with: with, **options
end

#label(attribute) ⇒ Object



36
37
38
# File 'lib/with_form/scope_form.rb', line 36

def label(attribute)
  translate(attribute, scope: [:helpers, :label, @scope])
end

#select(value, from:, **options) ⇒ Object



16
17
18
# File 'lib/with_form/scope_form.rb', line 16

def select(value, from:, **options)
  @page.select value, from: label(from), **options
end

#submit(action = nil) ⇒ Object



32
33
34
# File 'lib/with_form/scope_form.rb', line 32

def submit(action = nil)
  translate(action || :submit, scope: [:helpers, :submit, @scope])
end

#unselect(value, from:, **options) ⇒ Object



20
21
22
# File 'lib/with_form/scope_form.rb', line 20

def unselect(value, from:, **options)
  @page.unselect value, from: label(from), **options
end