Module: Capybara::TomSelect
- Defined in:
 - lib/decidim/dev/test/rspec_support/tom_select.rb
 
Instance Method Summary collapse
- 
  
    
      #tom_select(select_selector, option_id:)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
A helper for Capybara tests that need to set values from a tom-select.js input.
 
Instance Method Details
#tom_select(select_selector, option_id:) ⇒ Object
A helper for Capybara tests that need to set values from a tom-select.js input.
This is a really hacky approach using execute_javascript, but it works. Not sure if there is a better way, we could try actually interacting with the on-screen tom-select-provided UI, but we are taking the easy way out for now.
      17 18 19 20  | 
    
      # File 'lib/decidim/dev/test/rspec_support/tom_select.rb', line 17 def tom_select(select_selector, option_id:) js_str = %(document.querySelector("#{select_selector}").tomselect.setValue(#{option_id.inspect})) execute_script(js_str) end  |