mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Raise ArgumentError rather than warning when extra parameters passed to SelectorQuery
This commit is contained in:
parent
5b31ac1031
commit
6ef251e728
4 changed files with 10 additions and 8 deletions
|
@ -18,7 +18,7 @@ module Capybara
|
|||
@locator = args.shift
|
||||
@filter_block = filter_block
|
||||
|
||||
warn "Unused parameters passed to #{self.class.name} : #{args}" unless args.empty?
|
||||
raise ArgumentError, "Unused parameters passed to #{self.class.name} : #{args}" unless args.empty?
|
||||
|
||||
@expression = @selector.call(@locator, @options.merge(enable_aria_label: session_options.enable_aria_label))
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@ Capybara::SpecHelper.spec '#first' do
|
|||
expect(@session.first(@xpath).value).to eq('John')
|
||||
end
|
||||
|
||||
it "should warn when unused parameters are passed" do
|
||||
expect_any_instance_of(Kernel).to receive(:warn).with(/Unused parameters passed.*unused text/)
|
||||
@session.first(:css, 'h1', 'unused text')
|
||||
it "should raise when unused parameters are passed" do
|
||||
expect {
|
||||
@session.first(:css, 'h1', 'unused text')
|
||||
}.to raise_error ArgumentError, /Unused parameters passed.*unused text/
|
||||
end
|
||||
|
||||
context "with css selectors" do
|
||||
|
|
|
@ -72,9 +72,10 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|||
expect(@session).not_to have_selector("//p//a", text: /Red$/)
|
||||
end
|
||||
|
||||
it "should warn when extra parameters passed" do
|
||||
expect_any_instance_of(Kernel).to receive(:warn).with(/extra/)
|
||||
expect(@session).to have_selector(:css, "p a#foo", 'extra')
|
||||
it "should raise when extra parameters passed" do
|
||||
expect {
|
||||
expect(@session).to have_selector(:css, "p a#foo", 'extra')
|
||||
}.to raise_error ArgumentError, /extra/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ RSpec.describe Capybara do
|
|||
Capybara.default_host = old_default
|
||||
end
|
||||
|
||||
it "should warn if not a valid URL" do
|
||||
it "should raise if not a valid URL" do
|
||||
expect { Capybara.default_host = "www.example.com" }.to raise_error(ArgumentError, /Capybara\.default_host should be set to a url/)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue