Class: Formulaic::Inputs::StringInput

Inherits:
Input
  • Object
show all
Defined in:
lib/formulaic/inputs/string_input.rb

Instance Method Summary collapse

Methods inherited from Input

#initialize

Constructor Details

This class inherits a constructor from Formulaic::Inputs::Input

Instance Method Details

#fillObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/formulaic/inputs/string_input.rb', line 4

def fill
  if page.has_selector?(:fillable_field, input_text)
    fill_in(input_text, with: value)
  elsif page.has_selector?(:radio_button, input_text)
    choose(value)
  elsif has_option_in_select?(value, input_text)
    select(value, from: input_text)
  else
    raise Formulaic::InputNotFound.new(%[Unable to find input "#{input_text}".])
  end
end

#has_option_in_select?(option, select) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/formulaic/inputs/string_input.rb', line 20

def has_option_in_select?(option, select)
  find(:select, select).has_selector?(:option, option)
rescue Capybara::ElementNotFound
  false
end

#input_textObject



16
17
18
# File 'lib/formulaic/inputs/string_input.rb', line 16

def input_text
  @input_text ||= input(model_name, field)
end