Class: REXML::Element

Inherits:
Object
  • Object
show all
Includes:
AssertXPath::CommonXPathExtensions
Defined in:
lib/assert_xpath.rb,
lib/assert_xpath.rb

Instance Method Summary collapse

Methods included from AssertXPath::CommonXPathExtensions

#[], #identifiable?, #raise_magic_member_not_found, #symbolic?, #tribute

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object

:nodoc:



963
964
965
966
967
968
969
970
971
# File 'lib/assert_xpath.rb', line 963

def method_missing(*args, &block) #:nodoc:
  symbol = args.shift

  each_element("./#{symbol}") do |kid|
    return _bequeath_attributes(kid).drill(&block)
  end  #  ERGO  element/:child - def/

  raise_magic_member_not_found(symbol, caller)  #  ERGO  repurpose!
end

Instance Method Details

#attribute(name, namespace = nil) ⇒ Object



797
798
799
800
801
802
# File 'lib/assert_xpath.rb', line 797

def attribute( name, namespace=nil )
  prefix = nil
  prefix = namespaces.index(namespace) if namespace
  prefix = nil if prefix == 'xmlns'
  attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
end

#get_path(xpath) ⇒ Object Also known as: /

ERGO match??



985
986
987
988
# File 'lib/assert_xpath.rb', line 985

def get_path(xpath)
  node = each_element(xpath.to_s){}.first
  return _bequeath_attributes(node)  if node
end

#inner_text(interstitial = '') ⇒ Object

Returns all text contents from a node and its descendants

Example:

assert_match 'can\'t be blank', assert_tag_id(:div, :errorExplanation).inner_text.strip

%transclude AssertXPathSuite#test_inner_text



981
982
983
# File 'lib/assert_xpath.rb', line 981

def inner_text(interstitial = '')
  return self.each_element( './/text()' ){}.join(interstitial)
end

#search(xpath) ⇒ Object

Semi-private method to match Hpricotic abilities



959
960
961
# File 'lib/assert_xpath.rb', line 959

def search(xpath)
  return self.each_element( xpath ){}
end