remove deprecated only_path option

This commit is contained in:
Thomas Walpole 2017-10-08 14:56:17 -07:00
parent d5a855ac0a
commit d2670e3315
3 changed files with 7 additions and 36 deletions

View File

@ -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

View File

@ -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

View File

@ -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)