Module: PageRecord::Actions::ActionHandler
- Defined in:
- lib/page_record/actions.rb
Instance Method Summary collapse
-
#method_missing(action, message = nil) ⇒ Capybara::Element
This is the implementation of the page and record action routine.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(action, message = nil) ⇒ Capybara::Element
This is the implementation of the page and record action routine. It has two variants.
it has a ?
variant and a normal
variant.
normal variant: It checks the page for a data-action-for='action' tag somewhere on the page. If it finds it, it clicks it.
?
variant:
It checks the page for a data-action-for='action' tag somewhere on the page.
If it finds it, returns the Capybara result.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/page_record/actions.rb', line 47 def method_missing(action, = nil) raw_action = /(.*)\?/.match(action) begin if raw_action action_for?(raw_action[1]) else action_for(action) end rescue Capybara::Ambiguous ||= "Found multiple #{action} tags for #{@type} on page" raise MultipleRecords, rescue Capybara::ElementNotFound super end end |