Class: Wrapybara::Attribute

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/attribute.rb

Instance Method Summary collapse

Methods included from Element

#click, #default_how, #default_scope, #disabled?, #element, #element_identifier, #enabled?, #exists?, #focused?, #get_element, #parent_identifier, #path, #should_be_disabled, #should_be_enabled, #should_be_focused, #should_be_visible, #should_have_attribute, #should_not_be_disabled, #should_not_be_enabled, #should_not_be_focused, #should_not_be_visible, #should_not_have_attribute, #style, #visible?, #within

Constructor Details

#initialize(parent, attribute) ⇒ Attribute

Returns a new instance of Attribute.



5
6
7
8
# File 'lib/wrapybara/elements/attribute.rb', line 5

def initialize(parent, attribute)
	@parent = parent
	@attribute = attribute
end

Instance Method Details

#should_be(value) ⇒ Object

Raises:



22
23
24
25
# File 'lib/wrapybara/elements/attribute.rb', line 22

def should_be(value)
	message = "Expected element #{self.parent_identifier} to have attribute '#{@attribute}' with value '#{value}'"
	raise UnmetExpectation, message unless @parent.element[@attribute] == value
end

#should_existObject

Raises:



14
15
16
# File 'lib/wrapybara/elements/attribute.rb', line 14

def should_exist
	raise UnmetExpectation, "Expected element #{self.parent_identifier} to have attribute '#{@attribute}'" if @parent.element[@attribute].nil?
end

#should_not_be(value) ⇒ Object

Raises:



27
28
29
30
# File 'lib/wrapybara/elements/attribute.rb', line 27

def should_not_be(value)
	message = "Did not expect element #{self.parent_identifier} to have attribute '#{@attribute}' with value '#{value}'"
	raise UnmetExpectation, message if @parent.element[@attribute] == value
end

#should_not_existObject

Raises:



18
19
20
# File 'lib/wrapybara/elements/attribute.rb', line 18

def should_not_exist
	raise UnmetExpectation, "Did not expect element #{self.parent_identifier} to have attribute '#{@attribute}'" unless @parent.element[@attribute].nil?
end

#valueObject



10
11
12
# File 'lib/wrapybara/elements/attribute.rb', line 10

def value
	self
end