From b81aed55bb3c6ed6be37b3a2388ddf9a3d098119 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sat, 20 Jun 2020 16:21:59 -0700 Subject: [PATCH] validate text query types --- lib/capybara/queries/text_query.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/capybara/queries/text_query.rb b/lib/capybara/queries/text_query.rb index 634165f3..fd96ca67 100644 --- a/lib/capybara/queries/text_query.rb +++ b/lib/capybara/queries/text_query.rb @@ -6,6 +6,8 @@ module Capybara class TextQuery < BaseQuery def initialize(type = nil, expected_text, session_options:, **options) # rubocop:disable Style/OptionalArguments @type = type.nil? ? default_type : type + raise ArgumentError, '${@type} is not a valid type for a text query' unless valid_types.include?(@type) + @options = options super(@options) self.session_options = session_options @@ -89,6 +91,10 @@ module Capybara COUNT_KEYS + %i[wait exact normalize_ws] end + def valid_types + %i[all visible] + end + def check_visible_text? @type == :visible end