Module: Capybara::UI::WidgetParts::Struct::ClassMethods

Defined in:
lib/capybara/ui/widgets/parts/struct.rb

Instance Method Summary collapse

Instance Method Details

#attribute(name, selector, &block) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 10

def attribute(name, selector, &block)
  child = widget(name, selector, &block)

  class_eval "def \#{name}\nwidget(:\#{name}).value\nend\n"

  child
end

#boolean(name, selector, &block) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 22

def boolean(name, selector, &block)
  child = widget(name, selector, &block)

  class_eval "def \#{name}?\nwidget(:\#{name}).value\nend\n"

  child.class_eval "def value\nCapybara::UI::Conversions::Boolean(text)\nend\n"

  child
end

#date(name, selector, &block) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 40

def date(name, selector, &block)
  child = attribute(name, selector, &block)

  child.class_eval "def value\nDate.parse(text)\nend\n"

  child
end

#float(name, selector, &block) ⇒ Object


52
53
54
55
56
57
58
59
60
61
62
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 52

def float(name, selector, &block)
  child = attribute(name, selector, &block)

  child.class_eval "def value\nFloat(text)\nend\n"

  child
end

#integer(name, selector, &block) ⇒ Object


64
65
66
67
68
69
70
71
72
73
74
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 64

def integer(name, selector, &block)
  child = attribute(name, selector, &block)

  child.class_eval "def value\nInteger(text)\nend\n"

  child
end

#list(name, selector, options = {}, &block) ⇒ Object


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 76

def list(name, selector, options = {}, &block)
  child = widget(name, selector, Capybara::UI::List) do
    item options[:item_selector], options[:item_class] || ListItem
  end

  class_eval "def \#{name}\nwidget(:\#{name}).value\nend\n"

  child.class_eval(&block) if block_given?

  child
end

#string(name, *args, &block) ⇒ Object


92
93
94
95
96
97
98
99
100
101
102
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 92

def string(name, *args, &block)
  child = attribute(name, *args, &block)

  child.class_eval "def value\ntext\nend\n"

  child
end

#time(name, *args, &block) ⇒ Object


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/capybara/ui/widgets/parts/struct.rb', line 104

def time(name, *args, &block)
  child = attribute(name, *args, &block)

  child.class_eval "def value\nTime.parse(text)\nend\n"

  child
end