Sha256: 74c4f0ccd5142aacb7a853607cf30f7b982aa84a8dcdbd2b96936eddd9d0be4a

Contents?: true

Size: 785 Bytes

Versions: 49

Compression:

Stored size: 785 Bytes

Contents

require "webrat/core/locators/locator"

module Webrat
  module Locators

    class AreaLocator < Locator # :nodoc:

      def locate
        Area.load(@session, area_element)
      end

      def area_element
        area_elements.detect do |area_element|
          Webrat::XML.attribute(area_element, "title") =~ matcher ||
          Webrat::XML.attribute(area_element, "id") =~ matcher
        end
      end

      def matcher
        /#{Regexp.escape(@value.to_s)}/i
      end

      def area_elements
        Webrat::XML.xpath_search(@dom, Area.xpath_search)
      end

      def error_message
        "Could not find area with name #{@value}"
      end

    end

    def find_area(id_or_title) #:nodoc:
      AreaLocator.new(@session, dom, id_or_title).locate!
    end

  end
end

Version data entries

49 entries across 49 versions & 21 rubygems

Version Path
aslakhellesoy-webrat-0.4.4.1 lib/webrat/core/locators/area_locator.rb
casebook-webrat-0.4.4.1 lib/webrat/core/locators/area_locator.rb
cavalle-webrat-0.4.4.1 lib/webrat/core/locators/area_locator.rb
cavalle-webrat-0.4.4.2 lib/webrat/core/locators/area_locator.rb
davidtrogers-webrat-0.4.4.2 lib/webrat/core/locators/area_locator.rb
dbrady-webrat-0.4.4.1 lib/webrat/core/locators/area_locator.rb
dbrady-webrat-0.4.4.2 lib/webrat/core/locators/area_locator.rb
dbrady-webrat-0.4.4 lib/webrat/core/locators/area_locator.rb
diabolo-diabolo-webrat-0.4.4 lib/webrat/core/locators/area_locator.rb
diabolo-webrat-0.4.3 lib/webrat/core/locators/area_locator.rb
diabolo-webrat-0.4.4.1 lib/webrat/core/locators/area_locator.rb
diabolo-webrat-0.4.4.2 lib/webrat/core/locators/area_locator.rb
diabolo-webrat-0.4.4 lib/webrat/core/locators/area_locator.rb
dstrelau-webrat-0.5.1 lib/webrat/core/locators/area_locator.rb
emipair-webrat-0.0.1 lib/webrat/core/locators/area_locator.rb
futuresinc-webrat-0.4.4.100 lib/webrat/core/locators/area_locator.rb
futuresinc-webrat-0.4.4.99 lib/webrat/core/locators/area_locator.rb
garnierjm-webrat-0.4.5 lib/webrat/core/locators/area_locator.rb
hardbap-webrat-0.5.1 lib/webrat/core/locators/area_locator.rb
hardbap-webrat-0.5.2 lib/webrat/core/locators/area_locator.rb