Module: Test::Right::Widget::ClassMethods

Defined in:
lib/test/right/widget.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



7
8
9
# File 'lib/test/right/widget.rb', line 7

def location
  @location
end

#name_elementsObject (readonly)

Returns the value of attribute name_elements.



7
8
9
# File 'lib/test/right/widget.rb', line 7

def name_elements
  @name_elements
end

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/test/right/widget.rb', line 7

def root
  @root
end

#validatorObject (readonly)

Returns the value of attribute validator.



7
8
9
# File 'lib/test/right/widget.rb', line 7

def validator
  @validator
end

Instance Method Details

#[](name) ⇒ Object



57
58
59
# File 'lib/test/right/widget.rb', line 57

def [](name)
  WidgetProxy.new(self, name)
end

#action(name, &body) ⇒ Object



41
42
43
44
45
46
# File 'lib/test/right/widget.rb', line 41

def action(name, &body)
  define_method name do |*args|
    self.validate!
    self.instance_exec *args, &body
  end
end

#element(name, locator) ⇒ Object Also known as: button, field



13
14
15
# File 'lib/test/right/widget.rb', line 13

def element(name, locator)
  @selectors[name] = locator
end

#lives_at(url) ⇒ Object



17
18
19
# File 'lib/test/right/widget.rb', line 17

def lives_at(url)
  @location = url
end

#named_by(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/test/right/widget.rb', line 26

def named_by(*args)
  @name_elements ||= []
  if args.length == 2
    property, name_element = args
    @name_elements << [property, name_element.keys.first, name_element.values.first]
  else
    name_element = args.first
    @name_elements << [:text, name_element.keys.first, name_element.values.first]
  end
end

#property(name, &body) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/test/right/widget.rb', line 48

def property(name, &body)
  define_method name do
    self.validate!
    Value.new do
      self.instance_eval &body
    end
  end
end

#rooted_at(root) ⇒ Object



21
22
23
24
# File 'lib/test/right/widget.rb', line 21

def rooted_at(root)
  @root = [root.keys.first, root.values.first]
  @selectors[:root] = root
end

#selector(name) ⇒ Object



9
10
11
# File 'lib/test/right/widget.rb', line 9

def selector(name)
  @selectors[name]
end

#validated_by_presence_of(selector) ⇒ Object



37
38
39
# File 'lib/test/right/widget.rb', line 37

def validated_by_presence_of(selector)
  @validator = selector
end