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
Add "Testing View Partials" section to the Testing Guides #49193
Add "Testing View Partials" section to the Testing Guides #49193
Conversation
c93fdff
to
51348d4
Compare
@skipkayhil if you're available, I would appreciate some review on these changes. |
@zzak since they're largely documentation based, would you be interested in reviewing these changes? |
Motivation / Background --- While the `ActionView::TestCase` class isn't marked with a `:nodoc:` comment to indicate that it's internal to Rails, there isn't much content in the guides that explains how to test view partials. Libraries like [view_component](https://github.com/ViewComponent/view_component/) have [built-in support for testing](https://viewcomponent.org/guide/testing.html), including Capybara integration. While `ActionView::TestCase` already integrates with `rails-dom-testing`, that integration could be better documented. Additionally, it wouldn't take much for consuming applications to mimic the ViewComponent testing experience for their Action View Partials. Details --- First, link to the "Testing Rails Applications" page from the `ActionView::TestCase` class documentation. Next, add a "Testing View Partials" section to the guides that expands upon the variety of tooling available to tests that inherit from `ActionView::TestCase`. In that section, cover topics like: * the `render` helper method * the `rendered` helper attribute reader * calls to `assert_select` with attribute placeholders * the `document_root_element` helper method * integration with Ruby's Pattern Matching * opportunities to integrate with Capybara Additional Information --- Additionally, add test coverage that exercise the examples shared in the new section, including: * Calls to `assert_select` that utilize attribute placeholders * Ruby 3.0's Pattern Matching * Integration with Capybara
51348d4
to
a9148b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc changes look good on my end!
Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
@adrianna-chang-shopify thank you for the review! If you're interested, #49194 is related and in need of review. |
@seanpdoyle I'm not always able to read every notification from GitHub, in the future you can ping me on discord/slack/email 🙏 |
Motivation / Background
While the
ActionView::TestCase
class isn't marked with a:nodoc:
comment to indicate that it's internal to Rails, there isn't much content in the guides that explains how to test view partials.Libraries like view_component have built-in support for testing, including Capybara integration.
While
ActionView::TestCase
already integrates withrails-dom-testing
, that integration could be better documented. Additionally, it wouldn't take much for consuming applications to mimic the ViewComponent testing experience for their Action View Partials.Detail
First, link to the "Testing Rails Applications" page from the
ActionView::TestCase
class documentation.Next, add a "Testing View Partials" section to the guides that expands upon the variety of tooling available to tests that inherit from
ActionView::TestCase
. In that section, cover topics like:render
helper methodrendered
helper attribute readerassert_select
with attribute placeholdersdocument_root_element
helper methodAdditional information
Additionally, add test coverage that exercise the examples shared in the new section, including:
assert_select
that utilize attribute placeholdersChecklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]