Class: Formulaic::Inputs::StringInput
- Inherits:
-
Input
- Object
- Input
- Formulaic::Inputs::StringInput
show all
- Defined in:
- lib/formulaic/inputs/string_input.rb
Instance Method Summary
collapse
Methods inherited from Input
#initialize
Instance Method Details
#fill ⇒ Object
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
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_text ⇒ Object
16
17
18
|
# File 'lib/formulaic/inputs/string_input.rb', line 16
def input_text
@input_text ||= input(model_name, field)
end
|