Module: SelectHelper
- Includes:
- Capybara::DSL
- Defined in:
- lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/select_helper.rb
Instance Method Summary collapse
- #smart_select(value, from:) ⇒ Object (also: #select)
- #tailored_select(input, value) ⇒ Object
- #tom_select(input, value) ⇒ Object
Instance Method Details
#smart_select(value, from:) ⇒ Object Also known as: select
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/select_helper.rb', line 6 def smart_select(value, from:) label = find(:label, text: from, match: :first) input = find(id: label['for'], visible: :all) if input.tag_name == 'input' && input.native.attribute(:'aria-controls').include?('ts-dropdown') tom_select(input, value) elsif input.tag_name == 'tailored-select' tailored_select(input, value) else regular_select(value.to_s, from:) end end |
#tailored_select(input, value) ⇒ Object
19 20 21 22 |
# File 'lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/select_helper.rb', line 19 def tailored_select(input, value) option = input.find(:option, value, visible: :all) execute_script('arguments[0].click();', option) end |
#tom_select(input, value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/select_helper.rb', line 24 def tom_select(input, value) input.ancestor('.ts-control').click input.send_keys(value) sleep 0.5 # required due to bug in tom-select input.send_keys(:enter) end |