Skip to content

Commit

Permalink
Fix have/have_no_element and update obscured test
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Dec 12, 2023
1 parent 2052ea8 commit 52eaece
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/capybara/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/capybara/spec/views/with_html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ banana</textarea>
</div>
</details>

<div style='height: 1000px'>spacer</div>

<template id="template">
<input />
</template>
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/shared_spec_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
let(:html) { '<img src="/img.jpg" alt="a JPEG"><img src="/img.png" alt="a 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
Expand Down

0 comments on commit 52eaece

Please sign in to comment.