Sha256: a9321f089a01b377fdfcec1989e8ca4570e86f3bb105f68f3f0f1a7fa8187b84

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

module Webrat
  module Matchers
    
    class HaveSelector < HaveXpath #:nodoc:

      # ==== Returns
      # String:: The failure message.
      def failure_message
        "expected following text to match selector #{@expected}:\n#{@document}"
      end
    
      # ==== Returns
      # String:: The failure message to be displayed in negative matches.
      def negative_failure_message
        "expected following text to not match selector #{@expected}:\n#{@document}"
      end
    
      def query
        Nokogiri::CSS::Parser.parse(*super).map { |ast| ast.to_xpath }
      end
  
    end
    
    # Matches HTML content against a CSS 3 selector.
    #
    # ==== Parameters
    # expected<String>:: The CSS selector to look for.
    #
    # ==== Returns
    # HaveSelector:: A new have selector matcher.
    # ---
    # @api public
    def have_selector(expected)
      HaveSelector.new(expected)
    end
    alias_method :match_selector, :have_selector
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webrat-0.3.0 lib/webrat/core/matchers/have_selector.rb
webrat-0.3.1 lib/webrat/core/matchers/have_selector.rb