Allow have_xpath to accept options

This commit is contained in:
Bryan Helmkamp 2009-02-23 20:15:29 -05:00
parent 2296cadb93
commit 66d39b851c

View File

@ -5,8 +5,9 @@ module Webrat
module Matchers module Matchers
class HaveXpath #:nodoc: class HaveXpath #:nodoc:
def initialize(expected, &block) def initialize(expected, options = {}, &block)
@expected = expected @expected = expected
@options = {}
@block = block @block = block
end end
@ -77,18 +78,18 @@ module Webrat
# #
# ==== Returns # ==== Returns
# HaveXpath:: A new have xpath matcher. # HaveXpath:: A new have xpath matcher.
def have_xpath(expected, &block) def have_xpath(expected, options = {}, &block)
HaveXpath.new(expected, &block) HaveXpath.new(expected, options, &block)
end end
alias_method :match_xpath, :have_xpath alias_method :match_xpath, :have_xpath
def assert_have_xpath(expected, &block) def assert_have_xpath(expected, options = {}, &block)
hs = HaveXpath.new(expected, &block) hs = HaveXpath.new(expected, options, &block)
assert hs.matches?(response_body), hs.failure_message assert hs.matches?(response_body), hs.failure_message
end end
def assert_have_no_xpath(expected, &block) def assert_have_no_xpath(expected, options = {}, &block)
hs = HaveXpath.new(expected, &block) hs = HaveXpath.new(expected, options, &block)
assert !hs.matches?(response_body), hs.negative_failure_message assert !hs.matches?(response_body), hs.negative_failure_message
end end