brynary/webrat

View on GitHub
lib/webrat/core/elements/area.rb

Summary

Maintainability
A
25 mins
Test Coverage
require "webrat/core/elements/element"

module Webrat
  class Area < Element #:nodoc:

    def self.xpath_search
      [".//area"]
    end

    def click(method = nil, options = {})
      @session.request_page(absolute_href, :get, {})
    end

  protected

    def href
      @element["href"]
    end

    def absolute_href
      if href =~ /^\?/
        "#{@session.current_url}#{href}"
      elsif href !~ %r{^https?://[\w|.]+(/.*)} && (href !~ /^\//)
        "#{@session.current_url}/#{href}"
      else
        href
      end
    end

  end
end