Sha256: 4fdbf56124b79c0f098613a813809e0e8b017765f4edc465e11cbe8b26432978
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
module Webrat module Matchers class HasContent #:nodoc: def initialize(content) @content = content end def matches?(stringlike) if Webrat.configuration.parse_with_nokogiri? @document = Webrat.nokogiri_document(stringlike) else @document = Webrat.hpricot_document(stringlike) end @element = Webrat::XML.inner_text(@document) case @content when String @element.include?(@content) when Regexp @element.match(@content) end end # ==== Returns # String:: The failure message. def failure_message "expected the following element's content to #{content_message}:\n#{@element}" end # ==== Returns # String:: The failure message to be displayed in negative matches. def negative_failure_message "expected the following element's content to not #{content_message}:\n#{@element}" end def content_message case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end end # Matches the contents of an HTML document with # whatever string is supplied def contain(content) HasContent.new(content) end end end
Version data entries
5 entries across 5 versions & 4 rubygems