From d2670e331522c2069254e32473e5f5fc8d888d2e Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sun, 8 Oct 2017 14:56:17 -0700 Subject: [PATCH] remove deprecated only_path option --- lib/capybara/queries/current_path_query.rb | 20 ++++-------------- .../spec/session/assert_current_path.rb | 2 +- .../spec/session/has_current_path_spec.rb | 21 ++----------------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/lib/capybara/queries/current_path_query.rb b/lib/capybara/queries/current_path_query.rb index dd0c5d0e..3cd49ce9 100644 --- a/lib/capybara/queries/current_path_query.rb +++ b/lib/capybara/queries/current_path_query.rb @@ -8,12 +8,10 @@ module Capybara def initialize(expected_path, **options) super(options) @expected_path = expected_path - warn "DEPRECATED: The :only_path option is deprecated in favor of the :ignore_query option" if options.has_key?(:only_path) - @options = { url: !@expected_path.is_a?(Regexp) && !::Addressable::URI.parse(@expected_path || "").hostname.nil?, - only_path: false, - ignore_query: false }.merge(options) + ignore_query: false + }.merge(options) assert_valid_keys end @@ -23,11 +21,7 @@ module Capybara @actual_path = if options[:url] uri.to_s else - if options[:only_path] - uri && uri.path - else - uri && uri.request_uri - end + uri && uri.request_uri end if @expected_path.is_a? Regexp @@ -53,15 +47,9 @@ module Capybara end def valid_keys - [:wait, :url, :only_path, :ignore_query] + [:wait, :url, :ignore_query] end - def assert_valid_keys - super - if options[:url] && options[:only_path] - raise ArgumentError, "the :url and :only_path options cannot both be true" - end - end end end end diff --git a/lib/capybara/spec/session/assert_current_path.rb b/lib/capybara/spec/session/assert_current_path.rb index ca8710db..9fa26d8c 100644 --- a/lib/capybara/spec/session/assert_current_path.rb +++ b/lib/capybara/spec/session/assert_current_path.rb @@ -32,7 +32,7 @@ Capybara::SpecHelper.spec '#assert_current_path' do it "should ignore the query" do @session.visit('/with_js?test=test') - expect{@session.assert_current_path('/with_js', only_path: true)}.not_to raise_error + expect{@session.assert_current_path('/with_js', ignore_query: true)}.not_to raise_error end it "should not cause an exception when current_url is nil" do diff --git a/lib/capybara/spec/session/has_current_path_spec.rb b/lib/capybara/spec/session/has_current_path_spec.rb index ef52e659..6ce99bf3 100644 --- a/lib/capybara/spec/session/has_current_path_spec.rb +++ b/lib/capybara/spec/session/has_current_path_spec.rb @@ -73,32 +73,20 @@ Capybara::SpecHelper.spec '#has_current_path?' do it "should ignore the query" do @session.visit('/with_js?test=test') expect(@session).to have_current_path('/with_js?test=test') - expect(@session).to have_current_path('/with_js', only_path: true) expect(@session).to have_current_path('/with_js', ignore_query: true) uri = ::Addressable::URI.parse(@session.current_url) uri.query = nil expect(@session).to have_current_path(uri.to_s, ignore_query: true) end - it "should not allow url and only_path at the same time" do - expect { - expect(@session).to have_current_path('/with_js', url: true, only_path: true) - }.to raise_error ArgumentError - end - it "should not raise an exception if the current_url is nil" do allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil } - # Without only_path option + # Without ignore_query option expect { expect(@session).to have_current_path(nil) }.not_to raise_exception - # With only_path option - expect { - expect(@session).to have_current_path(nil, only_path: true) - }.not_to raise_exception - # With ignore_query option expect { expect(@session).to have_current_path(nil, ignore_query: true) @@ -134,16 +122,11 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do it "should not raise an exception if the current_url is nil" do allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil } - # Without only_path option + # Without ignore_query option expect { expect(@session).not_to have_current_path('/with_js') }. not_to raise_exception - # With only_path option - expect { - expect(@session).not_to have_current_path('/with_js', only_path: true) - }. not_to raise_exception - # With ignore_query option expect { expect(@session).not_to have_current_path('/with_js', ignore_query: true)