Module | SeleniumOnRails::PartialsSupport |
In: |
lib/selenium_on_rails/partials_support.rb
|
Provides partials support to test cases so they can include other partial test cases.
The partial‘s commands are returned as html table rows.
Extracts the commands from a partial. The partial must contain a html table and the first row is ignored since it cannot contain a command.
# File lib/selenium_on_rails/partials_support.rb, line 19 19: def extract_commands_from_partial partial 20: partial = partial.match(/.*<table>.*?<tr>.*?<\/tr>(.*?)<\/table>/im)[1] 21: raise "Partial '#{name}' doesn't contain any table" unless partial 22: partial 23: end
Overrides where the partial is searched for, and returns only the command table rows.
# File lib/selenium_on_rails/partials_support.rb, line 9 9: def render_partial partial_path = default_template_name, object = nil, local_assigns = nil, status = nil 10: pattern = partial_pattern partial_path 11: filename = Dir[pattern].first 12: raise "Partial '#{partial_path}' cannot be found! (Looking for file: '#{pattern}')" unless filename 13: partial = render :file => filename, :use_full_path => false, :locals => local_assigns 14: extract_commands_from_partial partial 15: end