Sha256: d61695122c48950862bd8886ec1f4d38bc13cca671f44e1c84269ef715605292

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true
module Capybara
  # @api private
  module Queries
    class TitleQuery < BaseQuery
      def initialize(expected_title, options = {})
        @expected_title = expected_title
        @options = options
        super(@options)
        unless @expected_title.is_a?(Regexp)
          @expected_title = Capybara::Helpers.normalize_whitespace(@expected_title)
        end
        @search_regexp = Capybara::Helpers.to_regexp(@expected_title, nil, options.fetch(:exact, false))
        assert_valid_keys
      end

      def resolves_for?(node)
        @actual_title = node.title
        @actual_title.match(@search_regexp)
      end

      def failure_message
        failure_message_helper
      end

      def negative_failure_message
        failure_message_helper(' not')
      end

      private

      def failure_message_helper(negated = '')
        verb = (@expected_title.is_a?(Regexp))? 'match' : 'include'
        "expected #{@actual_title.inspect}#{negated} to #{verb} #{@expected_title.inspect}"
      end

      def valid_keys
        [:wait, :exact]
      end
    end
  end
end

Version data entries

19 entries across 17 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/capybara-2.18.0/lib/capybara/queries/title_query.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/capybara-2.18.0/lib/capybara/queries/title_query.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/capybara-2.16.1/lib/capybara/queries/title_query.rb
capybara-2.18.0 lib/capybara/queries/title_query.rb
capybara-2.17.0 lib/capybara/queries/title_query.rb
tdiary-5.0.7 vendor/bundle/gems/capybara-2.16.1/lib/capybara/queries/title_query.rb
capybara-2.16.1 lib/capybara/queries/title_query.rb
capybara-2.16.0 lib/capybara/queries/title_query.rb
capybara-2.15.4 lib/capybara/queries/title_query.rb
capybara-2.15.3 lib/capybara/queries/title_query.rb
capybara-2.15.2 lib/capybara/queries/title_query.rb
tdiary-5.0.6 vendor/bundle/gems/capybara-2.15.1/lib/capybara/queries/title_query.rb
capybara-2.15.1 lib/capybara/queries/title_query.rb
capybara-2.15.0 lib/capybara/queries/title_query.rb
tdiary-5.0.5 vendor/bundle/gems/capybara-2.14.3/lib/capybara/queries/title_query.rb
capybara-2.14.4 lib/capybara/queries/title_query.rb
capybara-2.14.3 lib/capybara/queries/title_query.rb
capybara-2.14.2 lib/capybara/queries/title_query.rb
capybara-2.14.1 lib/capybara/queries/title_query.rb