You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a check that disallows passing exact_text to such matchers as that's unneeded - Capybara.exact makes these matcher work like so by default. That is, the above is equivalent to expect(page).to have_link('foobar').
A couple of things to note:
this is perhaps difficult to implement as Capybara.exact = true is generally set in a different file spec_helper.rb. Perhaps an option to the plugin could be passed, not sure?
I think we’d need to implement this via the cop configuration. The Capybara.exact= is dynamic code which is not executed by RuboCop and, as you mention, may not exist in the same file as the offense.
Just to be sure I understand this – is it correct that when Capybara.exact = true is set, we should change
Yes, that's correct. Also expect(page).to have_link(exact_text: "foo\nbar") shouldn't be changed. Also expect(page).to have_link(text: 'foobar') should not be changed because that doesn't look for an exact match but a partial one.
And yes, a cop-configuration is perhaps the way to go for this.
P.S. Code similar to find('td', exact_text: 'foo') and expect(page).to have_css('.some-class', exact_text: 'foo') also shouldn't be changed.
pirj
transferred this issue from rubocop/rubocop-rspec
Dec 29, 2022
It would be nice to have a check that disallows passing
exact_text
to such matchers as that's unneeded -Capybara.exact
makes these matcher work like so by default. That is, the above is equivalent toexpect(page).to have_link('foobar')
.A couple of things to note:
Capybara.exact = true
is generally set in a different filespec_helper.rb
. Perhaps an option to the plugin could be passed, not sure?exact_text
must be passed (because of Inconsistency betweenhas_css?
andfind_link
teamcapybara/capybara#2533).The text was updated successfully, but these errors were encountered: