lib/kelp/visibility.rb
# Verify the presence of content on the page. Passes when all the given items
# are found on the page, and fails if any of them are not found.
#
# @example
#   should_see "Animaniacs"
#   should_see ["Yakko", "Wakko", "Dot"]
#   should_see "Baloney", :within => "#slacks"
#   should_see /(Animaney|Totally Insaney|Pinky and the Brainy)/
#
# @param [String, Regexp, Array] texts
#   Text(s) or regexp(s) to look for
# @param [Hash] scope
#   Scoping keywords as understood by {#in_scope}
#
# @raise [Kelp::Unexpected]
#   If any of the expected text strings are not seen in the given scope
#
Verify the presence of content on the page. Passes when all the given items
are found on the page, and fails if any of them are not found.
Verify the presence of content on the page . Passes when all the given items are found on the page and fails if any of them are not found .
def should_see(texts, scope={})
      in_scope(scope) do
        texts = [texts] if (texts.class == String || texts.class == Regexp)
        unexpected = texts.select do |text|
          !page_contains?(text)
        end
        if !unexpected.empty?
          raise Kelp::Unexpected,
            "Expected to see: #{texts.inspect}\nDid not see: #{unexpected.inspect}"
        end
      end
    end
def should_see ( texts , scope = { } ) in_scope ( scope ) do texts = [ texts ] if ( texts . class == String || texts . class == Regexp ) unexpected = texts . select do | text | ! page_contains? ( text ) end if ! unexpected . empty? raise Kelp :: Unexpected , "Expected to see: #{texts.inspect}\nDid not see: #{unexpected.inspect}" end end end
Verify the presence of content on the page.
Verify the presence of content on the page .
# Select all expected values that don't appear on the page
[Kelp::Unexpected] If any of the expected text strings are not seen in the given scope
[ Kelp :: Unexpected ] If any of the expected text strings are not seen in the given scope
texts
<not_specific>
scope
<not_specific>
<not_specific>
scope Scoping keywords as understood by {#in_scope}
scope Scoping keywords as understood by { #in_scope }
example
should_see "Animaniacs" should_see ["Yakko", "Wakko", "Dot"] should_see "Baloney", :within => "#slacks" should_see /(Animaney|Totally Insaney|Pinky and the Brainy)
should_see " Animaniacs " should_see [ " Yakko " " Wakko " " Dot " ] should_see " Baloney " : within = > " #slacks " should_see / ( Animaney|Totally Insaney|Pinky and the Brainy )