Warn when extra parameters passed to SelectorQuery
This commit is contained in:
parent
2d9c1f21f0
commit
5807c466c6
|
@ -11,14 +11,16 @@ module Capybara
|
|||
@options = if args.last.is_a?(Hash) then args.pop.dup else {} end
|
||||
|
||||
if args[0].is_a?(Symbol)
|
||||
@selector = Selector.all[args[0]]
|
||||
@locator = args[1]
|
||||
@selector = Selector.all[args.shift]
|
||||
@locator = args.shift
|
||||
else
|
||||
@selector = Selector.all.values.find { |s| s.match?(args[0]) }
|
||||
@locator = args[0]
|
||||
@locator = args.shift
|
||||
end
|
||||
@selector ||= Selector.all[Capybara.default_selector]
|
||||
|
||||
warn "Unused parameters passed to #{self.class.name} : #{args.to_s}" unless args.empty?
|
||||
|
||||
# for compatibility with Capybara 2.0
|
||||
if Capybara.exact_options and @selector == Selector.all[:option]
|
||||
@options[:exact] = true
|
||||
|
|
|
@ -67,6 +67,11 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|||
expect(@session).to have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
|
||||
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')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue