Sha256: 0bb37bc77917a0ac56269ba7bb3d32879d7d338eecac90ae7eb36e0e7a324dc9

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

module Webrat
  class CulerityLocator
    def initialize(container, value, element_type, *how)
      @container    = container
      @value        = value
      @element_type = element_type
      @how          = how.blank? ? [:id, :name, :label] : how
    end

    def locate
      @how.each do |how|
        e = @container.send(@element_type, how => @value)
        return e if e.exists?
      end
      nil
    end

    def locate!
      locate || raise(NotFoundError.new("#{@element_type} matching \"#{@value}\" not found"))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dstrelau-webrat-0.5.1 lib/webrat/culerity/locator.rb