Class: Webrat::CulerityLocator

Inherits:
Object
  • Object
show all
Defined in:
lib/webrat/culerity/locator.rb

Instance Method Summary collapse

Constructor Details

#initialize(container, value, element_type, *how) ⇒ CulerityLocator

Returns a new instance of CulerityLocator.



3
4
5
6
7
8
# File 'lib/webrat/culerity/locator.rb', line 3

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

Instance Method Details

#locateObject



10
11
12
13
14
15
16
# File 'lib/webrat/culerity/locator.rb', line 10

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

#locate!Object



18
19
20
# File 'lib/webrat/culerity/locator.rb', line 18

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