2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2014-02-16 12:13:58 -05:00
|
|
|
module Capybara
|
|
|
|
# @api private
|
|
|
|
module Queries
|
|
|
|
class BaseQuery
|
|
|
|
COUNT_KEYS = [:count, :minimum, :maximum, :between]
|
|
|
|
|
|
|
|
attr_reader :options
|
|
|
|
|
|
|
|
def wait
|
2016-08-30 13:18:06 -04:00
|
|
|
self.class.wait(options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.wait(options)
|
2016-08-31 13:21:22 -04:00
|
|
|
options.fetch(:wait, Capybara.default_max_wait_time) || 0
|
2014-02-16 12:13:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def assert_valid_keys
|
|
|
|
invalid_keys = @options.keys - valid_keys
|
|
|
|
unless invalid_keys.empty?
|
|
|
|
invalid_names = invalid_keys.map(&:inspect).join(", ")
|
|
|
|
valid_names = valid_keys.map(&:inspect).join(", ")
|
|
|
|
raise ArgumentError, "invalid keys #{invalid_names}, should be one of #{valid_names}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|