Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Conversation

@jjaffeux
Copy link
Contributor

Generally speaking we never want to do:

expect(element.text).to eq("foo")

As these are rspec matchers and do not add further Capybara-style waiting specifically for the text content to become present.

Generally speaking we never want to do:

```
expect(element.text).to eq("foo")
```

As these are rspec matchers and do not add further Capybara-style waiting specifically for the text content to become present.
iframe_selector = "#{artifact_element_selector} iframe"
artifact_element = find(artifact_element_selector)

expect(page).to have_css(iframe_selector)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing a find at tnetx step so I don't think that's necessary, we will fail on the find if it doesn’t exist

expect(iframe_element["data-custom-message"]).to eq("hello-from-post")
expect(iframe_element["data-post-author-id"]).to eq(author.id.to_s)
expect(artifact_element).to have_css("iframe[data-custom-message='hello-from-post']")
expect(artifact_element).to have_css("iframe[data-post-author-id='#{author.id}']")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't check data attributes on the element itself in capybara, so the best way is to do this.

Comment on lines +62 to +64
expect(page).to have_selector(data_selector, text: /.+/)
expect(page).to have_no_selector(data_selector, text: "Waiting for data...")
expect(page).to have_no_selector(data_selector, text: "Error:")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to use rspec matcher on dom elements, they are not waiting correctly

@SamSaffron SamSaffron merged commit 296aa24 into main May 19, 2025
6 checks passed
@SamSaffron SamSaffron deleted the idiomatic-spec-1 branch May 19, 2025 21:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants