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

Delegate Capybara::Result#to_ary #2733

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

seanpdoyle
Copy link
Contributor

Delegate to Capybara::Result#full_results in order to support Ruby's multiple assignment:

node = Capybara.string <<~HTML
  <ul>
    <li>Alpha</li>
    <li>Beta</li>
    <li>Gamma</li>
    <li>Delta</li>
  </ul>
HTML

first, *rest, last = node.all("//li", minimum: 0)

expect(first).to have_text "Alpha"
expect(rest.first).to have_text "Beta"
expect(rest.last).to have_text "Gamma"
expect(last).to have_text "Delta"

Delegate to `Capybara::Result#full_results` in order to support Ruby's
multiple assignment:

```ruby
node = Capybara.string <<~HTML
  <ul>
    <li>Alpha</li>
    <li>Beta</li>
    <li>Gamma</li>
    <li>Delta</li>
  </ul>
HTML

first, *rest, last = node.all("//li", minimum: 0)

expect(first).to have_text "Alpha"
expect(rest.first).to have_text "Beta"
expect(rest.last).to have_text "Gamma"
expect(last).to have_text "Delta"
```
@twalpole twalpole merged commit 1857cb1 into teamcapybara:master Jan 26, 2024
@seanpdoyle seanpdoyle deleted the splat-results branch January 26, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants