Module: PathSelectorFallbacks

Defined in:
lib/spreewald_support/path_selector_fallbacks.rb

Instance Method Summary collapse

Instance Method Details

#_path_to(page_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/spreewald_support/path_selector_fallbacks.rb', line 15

def _path_to(page_name)
  if respond_to?(:path_to)
    path_to(page_name)
  else
    begin
      page_name =~ /^the (.*) page$/
      path_components = $1.split(/\s+/)
      self.send(path_components.push('path').join('_').to_sym)
    rescue NoMethodError, ArgumentError
      raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
        "Add and require a paths.rb file (compare #{Spreewald.github_url}/examples/paths.rb)"
    end
  end
end

#_selector_for(locator) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/spreewald_support/path_selector_fallbacks.rb', line 4

def _selector_for(locator)
  if respond_to?(:selector_for)
    selector_for(locator)
  elsif locator =~ /^"(.+)"$/
    $1
  else
    raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
      "Add and require a selectors.rb file (compare #{Spreewald.github_url}/examples/selectors.rb)"
  end
end