Class: Hpricot::Elem

Inherits:
Object show all
Defined in:
lib/merb-core/test/test_ext/hpricot.rb

Overview

yehudakatz.com/2007/01/27/a-better-assert_select-assert_elements/ based on assert_elements Author: Yehuda Katz Email: wycats @nospam@ gmail.com Web: www.yehudakatz.com

which was based on HpricotTestHelper Author: Luke Redpath Email: contact @nospam@ lukeredpath.co.uk Web: www.lukeredpath.co.uk / opensource.agileevolved.com

Instance Method Summary collapse

Instance Method Details

#contain?(value) ⇒ Boolean Also known as: contains?

Returns:

  • (Boolean)


13
14
15
# File 'lib/merb-core/test/test_ext/hpricot.rb', line 13

def contain?(value)
  self.inner_text.include?(value)
end

#inner_textObject

courtesy of ‘thomas’ from the comments of _whys blog - get in touch if you want a better credit!



27
28
29
30
31
# File 'lib/merb-core/test/test_ext/hpricot.rb', line 27

def inner_text
  self.children.collect do |child|
    child.is_a?(Hpricot::Text) ? child.content : ((child.respond_to?("inner_text") && child.inner_text) || "")
  end.join.strip
end

#match?(regex) ⇒ Boolean Also known as: matches?

Returns:

  • (Boolean)


19
20
21
# File 'lib/merb-core/test/test_ext/hpricot.rb', line 19

def match?(regex)
  self.inner_text.match(regex)
end