From 52eaecea6d154b7d664b0032cd1cbcad4788fe65 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Mon, 11 Dec 2023 17:58:09 -0800 Subject: [PATCH] Fix have/have_no_element and update obscured test --- lib/capybara/rspec/matchers.rb | 4 ++-- lib/capybara/spec/views/with_html.erb | 2 ++ spec/rspec/shared_spec_matchers.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/capybara/rspec/matchers.rb b/lib/capybara/rspec/matchers.rb index 8d9b10898..a7a0f452f 100644 --- a/lib/capybara/rspec/matchers.rb +++ b/lib/capybara/rspec/matchers.rb @@ -77,7 +77,7 @@ def match_selector(...) # # @see Capybara::Node::Matchers#matches_css? - %i[link button field select table].each do |selector| + %i[link button field select table element].each do |selector| define_method "have_#{selector}" do |locator = nil, **options, &optional_filter_block| Matchers::HaveSelector.new(selector, locator, **options, &optional_filter_block) end @@ -166,7 +166,7 @@ def have_style(styles = nil, **options) %w[selector css xpath text title current_path link button field checked_field unchecked_field select table - sibling ancestor].each do |matcher_type| + sibling ancestor element].each do |matcher_type| define_method "have_no_#{matcher_type}" do |*args, **kw_args, &optional_filter_block| Matchers::NegatedMatcher.new(send("have_#{matcher_type}", *args, **kw_args, &optional_filter_block)) end diff --git a/lib/capybara/spec/views/with_html.erb b/lib/capybara/spec/views/with_html.erb index 42d508c75..b7fcae6fb 100644 --- a/lib/capybara/spec/views/with_html.erb +++ b/lib/capybara/spec/views/with_html.erb @@ -200,6 +200,8 @@ banana +
spacer
+ diff --git a/spec/rspec/shared_spec_matchers.rb b/spec/rspec/shared_spec_matchers.rb index f56895848..0ed1877b9 100644 --- a/spec/rspec/shared_spec_matchers.rb +++ b/spec/rspec/shared_spec_matchers.rb @@ -507,7 +507,7 @@ let(:html) { 'a JPEGa PNG' } it 'gives proper description' do - expect(have_element('img').description).to eq('have element "img"') + expect(have_element('img').description).to eq('have visible element "img"') end it 'passes if there is such a element' do