Module: WithinHelpers
- Defined in:
- lib/spreewald_support/path_selector_fallbacks.rb
Instance Method Summary collapse
Instance Method Details
#deconstruct_selector(selector) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/spreewald_support/path_selector_fallbacks.rb', line 43 def deconstruct_selector(selector) if selector.is_a?(Array) if selector[-1].is_a?(Hash) # selector with keyword arguments, e.g. ['.foo', { text: 'bar', visible: :all }] [selector[0...-1], **selector[-1]] else # xpath selector, e.g. [:xpath, '//header'] [selector, {}] end else # String or Capybara::Node::Element [selector, {}] end end |
#with_scope(locator) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/spreewald_support/path_selector_fallbacks.rb', line 33 def with_scope(locator) if locator selector = _selector_for(locator) args, kwargs = deconstruct_selector(selector) within(*args, **kwargs) { yield } else yield end end |