From 8f5f55af895d67c4b58503050e8e782b265ad2b1 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sun, 28 May 2017 08:54:55 -0700 Subject: [PATCH] Fix Ruby warnings during tests --- lib/capybara/queries/base_query.rb | 4 ++++ lib/capybara/queries/current_path_query.rb | 1 + lib/capybara/queries/selector_query.rb | 2 +- lib/capybara/queries/text_query.rb | 2 +- lib/capybara/queries/title_query.rb | 1 + lib/capybara/rack_test/driver.rb | 1 + lib/capybara/rspec/matcher_proxies.rb | 16 ++++++++++------ lib/capybara/rspec/matchers.rb | 1 + lib/capybara/selenium/driver.rb | 1 + spec/minitest_spec_spec.rb | 8 ++++---- spec/per_session_config_spec.rb | 8 ++++---- 11 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/capybara/queries/base_query.rb b/lib/capybara/queries/base_query.rb index 1a1ed0f6..60d23000 100644 --- a/lib/capybara/queries/base_query.rb +++ b/lib/capybara/queries/base_query.rb @@ -8,6 +8,10 @@ module Capybara attr_reader :options attr_writer :session_options + def initialize(options) + @session_options = options.delete(:session_options) + end + def session_options @session_options || Capybara.session_options end diff --git a/lib/capybara/queries/current_path_query.rb b/lib/capybara/queries/current_path_query.rb index edf971ff..9a999994 100644 --- a/lib/capybara/queries/current_path_query.rb +++ b/lib/capybara/queries/current_path_query.rb @@ -6,6 +6,7 @@ module Capybara module Queries class CurrentPathQuery < BaseQuery def initialize(expected_path, options = {}) + super(options) @expected_path = expected_path @options = { url: false, diff --git a/lib/capybara/queries/selector_query.rb b/lib/capybara/queries/selector_query.rb index dae2a49a..f4b03f7e 100644 --- a/lib/capybara/queries/selector_query.rb +++ b/lib/capybara/queries/selector_query.rb @@ -9,7 +9,7 @@ module Capybara def initialize(*args, &filter_block) @options = if args.last.is_a?(Hash) then args.pop.dup else {} end - self.session_options = @options.delete(:session_options) + super(@options) @filter_block = filter_block diff --git a/lib/capybara/queries/text_query.rb b/lib/capybara/queries/text_query.rb index 7537a90d..36468ad4 100644 --- a/lib/capybara/queries/text_query.rb +++ b/lib/capybara/queries/text_query.rb @@ -7,7 +7,7 @@ module Capybara @type = (args.first.is_a?(Symbol) || args.first.nil?) ? args.shift : nil # @type = (Capybara.ignore_hidden_elements or Capybara.visible_text_only) ? :visible : :all if @type.nil? @options = if args.last.is_a?(Hash) then args.pop.dup else {} end - self.session_options = @options.delete(:session_options) + super(@options) @type = (session_options.ignore_hidden_elements or session_options.visible_text_only) ? :visible : :all if @type.nil? diff --git a/lib/capybara/queries/title_query.rb b/lib/capybara/queries/title_query.rb index f1bebdea..043ef84e 100644 --- a/lib/capybara/queries/title_query.rb +++ b/lib/capybara/queries/title_query.rb @@ -6,6 +6,7 @@ module Capybara 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 diff --git a/lib/capybara/rack_test/driver.rb b/lib/capybara/rack_test/driver.rb index 21952ba7..013406ed 100644 --- a/lib/capybara/rack_test/driver.rb +++ b/lib/capybara/rack_test/driver.rb @@ -15,6 +15,7 @@ class Capybara::RackTest::Driver < Capybara::Driver::Base def initialize(app, options={}) raise ArgumentError, "rack-test requires a rack application, but none was given" unless app + @session = nil @app = app @options = DEFAULT_OPTIONS.merge(options) end diff --git a/lib/capybara/rspec/matcher_proxies.rb b/lib/capybara/rspec/matcher_proxies.rb index a6233e12..110fe8ce 100644 --- a/lib/capybara/rspec/matcher_proxies.rb +++ b/lib/capybara/rspec/matcher_proxies.rb @@ -19,14 +19,18 @@ module Capybara end module DSL - def self.included(base) - warn "including Capybara::DSL in the global scope is not recommended!" if base == Object + class <