Class: Webrat::CulerityScope

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ CulerityScope

Returns a new instance of CulerityScope.



5
6
7
# File 'lib/webrat/culerity/scope.rb', line 5

def initialize(container)
  @container = container
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



3
4
5
# File 'lib/webrat/culerity/scope.rb', line 3

def container
  @container
end

Instance Method Details

#check(id_or_name_or_label, value = true) ⇒ Object



9
10
11
12
# File 'lib/webrat/culerity/scope.rb', line 9

def check(id_or_name_or_label, value = true)
  elem = element_locator(id_or_name_or_label, :check_box)
  elem.set(value)
end

#choose(id_or_name_or_label) ⇒ Object



16
17
18
19
# File 'lib/webrat/culerity/scope.rb', line 16

def choose(id_or_name_or_label)
  elem = element_locator(id_or_name_or_label, :radio)
  elem.set
end

#click_button(value_or_id_or_alt = nil, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/webrat/culerity/scope.rb', line 23

def click_button(value_or_id_or_alt = nil, options = {})
  options = value_or_id_or_alt if value_or_id_or_alt.is_a?(Hash)

  with_handler options.delete(:confirm) do
    if value_or_id_or_alt
      elem = element_locator(value_or_id_or_alt, :button, :value, :id, :text, :alt)
    else
      elem = container.buttons[0] # celerity should really include Enumerable here
    end
    elem.click
  end
end


38
39
40
41
42
43
# File 'lib/webrat/culerity/scope.rb', line 38

def click_link(text_or_title_or_id, options = {})
  with_handler options.delete(:confirm) do
    elem = element_locator(text_or_title_or_id, :link, :text, :title, :id)
    elem.click
  end
end

#field_by_xpath(xpath) ⇒ Object



47
48
49
# File 'lib/webrat/culerity/scope.rb', line 47

def field_by_xpath(xpath)
  element_locator(xpath, :generic_field, :xpath)
end

#field_labeled(label) ⇒ Object



51
52
53
# File 'lib/webrat/culerity/scope.rb', line 51

def field_labeled(label)
  element_locator(label, :generic_field, :label)
end

#field_with_id(id) ⇒ Object



55
56
57
# File 'lib/webrat/culerity/scope.rb', line 55

def field_with_id(id)
  element_locator(id, :generic_field, :id)
end

#fill_in(id_or_name_or_label, options = {}) ⇒ Object



59
60
61
62
# File 'lib/webrat/culerity/scope.rb', line 59

def fill_in(id_or_name_or_label, options = {})
  elem = element_locator(id_or_name_or_label, :text_field)
  elem.set(options[:with])
end

#response_bodyObject



66
67
68
# File 'lib/webrat/culerity/scope.rb', line 66

def response_body
  container.html
end

#select(option_text, options = {}) ⇒ Object



70
71
72
73
# File 'lib/webrat/culerity/scope.rb', line 70

def select(option_text, options = {})
  elem = element_locator(options[:from], :select_list)
  elem.select(option_text)
end

#uncheck(id_or_name_or_label) ⇒ Object



77
78
79
# File 'lib/webrat/culerity/scope.rb', line 77

def uncheck(id_or_name_or_label)
  check(id_or_name_or_label, false)
end