Use NegatedMatcher for not_match_xxx matchers
This commit is contained in:
parent
618dd9ff70
commit
06e16b04ce
|
@ -274,8 +274,6 @@ module Capybara
|
|||
MatchSelector.new(*args, &optional_filter_block)
|
||||
end
|
||||
|
||||
::RSpec::Matchers.define_negated_matcher :not_match_selector, :match_selector if defined?(::RSpec::Matchers)
|
||||
|
||||
# RSpec matcher for whether elements(s) matching a given xpath selector exist
|
||||
# See {Capybara::Node::Matchers#has_xpath?}
|
||||
def have_xpath(xpath, **options, &optional_filter_block)
|
||||
|
@ -364,6 +362,12 @@ module Capybara
|
|||
end
|
||||
alias_method :have_no_content, :have_no_text
|
||||
|
||||
%w[selector css xpath].each do |matcher_type|
|
||||
define_method "not_match_#{matcher_type}" do |*args, &optional_filter_block|
|
||||
NegatedMatcher.new(send("match_#{matcher_type}", *args, &optional_filter_block))
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Wait for window to become closed.
|
||||
# @example
|
||||
|
|
|
@ -253,7 +253,7 @@ Capybara::SpecHelper.spec '#has_no_text?' do
|
|||
expect(@session).not_to have_no_text('exercitation ullamco laboris')
|
||||
end
|
||||
|
||||
it "should be true if the given text is not on the page", :focus_ do
|
||||
it "should be true if the given text is not on the page" do
|
||||
@session.visit('/with_html')
|
||||
expect(@session).to have_no_text('xxxxyzzz')
|
||||
expect(@session).to have_no_text('monkey')
|
||||
|
|
Loading…
Reference in New Issue