Sha256: af5c55cb8e9c6cb74522a073ce6a0631bf6c5376bfdd67b5dc02ecf5e05b12f9

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 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, &block)
      HaveSelector.new(expected, &block)
    end
    alias_method :match_selector, :have_selector
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webrat-0.3.4 lib/webrat/core/matchers/have_selector.rb
webrat-0.3.2 lib/webrat/core/matchers/have_selector.rb
webrat-0.3.3 lib/webrat/core/matchers/have_selector.rb