Sha256: 18038d5ee44ee338e06479d38e21ccb97f1a96cc99a6491b2f90ae9e36678f37

Contents?: true

Size: 810 Bytes

Versions: 5

Compression:

Stored size: 810 Bytes

Contents

module Webrat
  class Area #:nodoc:
    
    def initialize(session, element)
      @session  = session
      @element  = element
    end
    
    def click(method = nil, options = {})
      @session.request_page(absolute_href, :get, {})
    end
    
    def matches_text?(id_or_title)
      matcher = /#{Regexp.escape(id_or_title.to_s)}/i
      title =~ matcher || id =~ matcher
    end
    
    protected
    
    def href
      @element["href"]
    end
    
    def title
      @element["title"]
    end
    
    def id
      @element["id"]
    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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
webrat-0.3.1 lib/webrat/core/area.rb
webrat-0.3.0 lib/webrat/core/area.rb
webrat-0.3.3 lib/webrat/core/area.rb
webrat-0.3.2 lib/webrat/core/area.rb
webrat-0.3.4 lib/webrat/core/area.rb