Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capybara/FindAllFirst applies incorrect rewrite #150

Open
fdr opened this issue Mar 13, 2025 · 0 comments
Open

Capybara/FindAllFirst applies incorrect rewrite #150

fdr opened this issue Mar 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@fdr
Copy link

fdr commented Mar 13, 2025

per ubicloud/ubicloud#2974 (comment), this applies rewrites like the following, caused by upgrade to 2.22.1:

diff --git a/spec/routes/web/access_control_spec.rb b/spec/routes/web/access_control_spec.rb
index 4e1bf343..b4b7bf0b 100644
--- a/spec/routes/web/access_control_spec.rb
+++ b/spec/routes/web/access_control_spec.rb
@@ -18,7 +18,7 @@
     def displayed_access_control_entries
       page.all("table#access-control-entries .existing-aces-view td.values").map(&:text) +
         page.all("table#access-control-entries .existing-aces select")
-          .map { |select| select.all("option[selected]")[0] || select.first("option") }
+          .map { |select| select.first("option[selected]") || select.first("option") }
           .map(&:text)
     end
 
diff --git a/spec/routes/web/token_spec.rb b/spec/routes/web/token_spec.rb
index 05dd11f8..9ad40978 100644
--- a/spec/routes/web/token_spec.rb
+++ b/spec/routes/web/token_spec.rb
@@ -11,7 +11,7 @@
   def displayed_access_control_entries
     page.all("table#access-control-entries .existing-aces-view td.values").map(&:text) +
       page.all("table#access-control-entries .existing-aces select")
-        .map { |select| select.all("option[selected]")[0] || select.first("option") }
+        .map { |select| select.first("option[selected]") || select.first("option") }
         .map(&:text)
   end

But, this breaks the tests, with errors like:

  1) Clover access control authenticated can create access control entries
     Failure/Error:
       page.all("table#access-control-entries .existing-aces select")
         .map { |select| select.first("option[selected]") || select.first("option") }
         .map(&:text)

     Capybara::ExpectationNotMet:
       expected to find css "option[selected]" within #<Capybara::Node::Element tag="select" path="/html/body/div[1]/div[3]/main/div/div/div[4]/form/div/table/tbody/tr[2]/td[2]/div/select"> at least 1 time but there were no matches

Let me know if you need more information. Thank you.

@ydah ydah added the bug Something isn't working label Mar 13, 2025
fdr added a commit to ubicloud/ubicloud that referenced this issue Mar 17, 2025
I want to table this upgrade while upstream figures out
`Capybara/FindAllFirst`, or, failing that, stop using
`rubocopy-capybara`.

d03a9e5 was not effective, as
Dependabot takes it upon itself not only to satisfy the Gemfile, but
to update it as well when people use the `~>` operator.  I suppose
this comes from a long history of people using `~>` without a plan to
be notified about new releases that do not satisfy it.

I filed the `FindAllFirst` as an issue:
rubocop/rubocop-capybara#150

Using a `<` operator ought to be more prescriptive.  I am not sure how
to conveniently test dependabot's behavior without a merge, though.
fdr added a commit to ubicloud/ubicloud that referenced this issue Mar 17, 2025
I want to table this upgrade while upstream figures out
`Capybara/FindAllFirst`, or, failing that, stop using
`rubocopy-capybara`.

d03a9e5 was not effective, as
Dependabot takes it upon itself not only to satisfy the Gemfile, but
to update it as well when people use the `~>` operator.  I suppose
this comes from a long history of people using `~>` without a plan to
be notified about new releases that do not satisfy it.

I filed the `FindAllFirst` as an issue:
rubocop/rubocop-capybara#150

Using a `<` operator ought to be more prescriptive.  I am not sure how
to conveniently test dependabot's behavior without a merge, though.
fdr added a commit to ubicloud/ubicloud that referenced this issue Mar 17, 2025
I want to table this upgrade while upstream figures out
`Capybara/FindAllFirst`, or, failing that, stop using
`rubocopy-capybara`.

d03a9e5 was not effective, as
Dependabot takes it upon itself not only to satisfy the Gemfile, but
to update it as well when people use the `~>` operator.  I suppose
this comes from a long history of people using `~>` without a plan to
be notified about new releases that do not satisfy it.

I filed the `FindAllFirst` as an issue:
rubocop/rubocop-capybara#150

Using a `<` operator ought to be more prescriptive.  I am not sure how
to conveniently test dependabot's behavior without a merge, though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants