mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Refactor
This commit is contained in:
parent
847191ab42
commit
1c6ea8ac3e
1 changed files with 3 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
module Capybara
|
module Capybara
|
||||||
class Query
|
class Query
|
||||||
attr_accessor :selector, :locator, :options, :xpaths
|
attr_accessor :selector, :locator, :options, :xpath
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@options = if args.last.is_a?(Hash) then args.pop.dup else {} end
|
@options = if args.last.is_a?(Hash) then args.pop.dup else {} end
|
||||||
|
@ -19,16 +19,12 @@ module Capybara
|
||||||
|
|
||||||
xpath = @selector.call(@locator)
|
xpath = @selector.call(@locator)
|
||||||
if xpath.respond_to?(:to_xpaths)
|
if xpath.respond_to?(:to_xpaths)
|
||||||
@xpaths = [xpath.to_xpath(:fuzzy)]
|
@xpath = xpath.to_xpath(:fuzzy)
|
||||||
else
|
else
|
||||||
@xpaths = [xpath.to_s]
|
@xpath = xpath.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def xpath
|
|
||||||
xpaths.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def failure_message(type, node)
|
def failure_message(type, node)
|
||||||
message = selector.failure_message.call(node, self) if selector.failure_message
|
message = selector.failure_message.call(node, self) if selector.failure_message
|
||||||
message ||= options[:message]
|
message ||= options[:message]
|
||||||
|
|
Loading…
Add table
Reference in a new issue