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:



944
945
946
947
948
949
950
951
952
# File 'lib/assert_xpath.rb', line 944

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



776
777
778
779
780
781
# File 'lib/assert_xpath.rb', line 776

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??



966
967
968
969
# File 'lib/assert_xpath.rb', line 966

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



962
963
964
# File 'lib/assert_xpath.rb', line 962

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

#search(xpath) ⇒ Object

Semi-private method to match Hpricotic abilities



940
941
942
# File 'lib/assert_xpath.rb', line 940

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