I'm wondering if there is a way to create custom methods that allow me to "chain" calls against a Capybara object. This may be difficult to explain so here's an example that I'm trying to achieve:
find('#element-id').some_custom_method_here
find('#another-element-id').some_custom_method_here
all('.other-class-id')[3].some_custom_method_here
I'd like to be able to use custom class methods on a Capybara object, so that I might be able to find/manipulate/perform actions within a specific part of the DOM that might allow easy re-usability throughout a page.
The only way I've found myself being able to do this is by creating a function that passes the element first, and then moves on with my code. Like this:
def some_custom_method_here(capybara_obj, options={})
# do stuff with capybara_obj, find, click, etc
end