Sha256: 3a12058d45fe960a37c4e5de0cdd18953acc42c766fbe4a8f38e661e925c45f8

Contents?: true

Size: 888 Bytes

Versions: 23

Compression:

Stored size: 888 Bytes

Contents

# http://yehudakatz.com/2007/01/27/a-better-assert_select-assert_elements/
# based on assert_elements
# Author: Yehuda Katz
# Email:  wycats @nospam@ gmail.com
# Web:    http://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

class Hpricot::Elem
  def contain?(value)
    self.inner_text.include?(value)
  end
  
  alias_method :contains?, :contain?

  def match?(regex)
    self.inner_text.match(regex)
  end
  
  alias_method :matches?, :match?
  
  # courtesy of 'thomas' from the comments
  # of _whys blog - get in touch if you want a better credit!
  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
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
joe-merb-core-0.9.8 lib/merb-core/test/test_ext/hpricot.rb
wycats-merb-core-0.9.8 lib/merb-core/test/test_ext/hpricot.rb
wycats-merb-core-0.9.9 lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/test/test_ext/hpricot.rb
thorero-0.9.4.5 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.10 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.12 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.2 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.11 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.13 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.3 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.4 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.5 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.6 lib/merb-core/test/test_ext/hpricot.rb
merb-core-0.9.7 lib/merb-core/test/test_ext/hpricot.rb