-
Notifications
You must be signed in to change notification settings - Fork 443
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 render_preview
test helper
#1347
Conversation
@@ -41,14 +41,49 @@ def refute_component_rendered | |||
# @param component [ViewComponent::Base, ViewComponent::Collection] The instance of the component to be rendered. | |||
# @return [Nokogiri::HTML] | |||
def render_inline(component, **args, &block) | |||
@rendered_component = | |||
@rendered_content = |
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.
Super minor, but I wonder if this is being used directly by any libraries/apps and if renaming it would break anything.
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.
I do wonder that too. I'll add a note to the changelog.
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.
This indeed is used by lots of people! #1372 and #1373 offer two fixes.
I wonder if we should update the documentation to more explicitly direct people towards writing expectations that use page
if they are using RSpec and Capybara?
expect(page).to have_link("Home page", href: root_path)
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.
Related issue: #1375
@@ -23,6 +23,8 @@ def index | |||
end | |||
|
|||
def previews | |||
find_preview |
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.
Just curious, why was this change necessary?
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.
Good question. Since we're calling previews
directly from render_preview
, before_action
isn't called. In fact, I think we could inline find_preview
here!
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.
I like this a lot!
Similar to how we adopted i18n, slots v2 , and other features, what are your thoughts on extracting the test functionality into it's own namespace and not include it by default? That way we can make breaking changes as/if needed without needing a major release.
Co-authored-by: Blake Williams <blakewilliams@github.com>
Co-authored-by: Blake Williams <blakewilliams@github.com>
31423cb
to
45daf39
Compare
In working on #1347, @camertron and I realized that it's a little strange to have our test suite in two places. In the interest of having our suite serve as an example for consumers of the framework, we decided to move everything into the sandbox application.
* Move tests into sandbox directory In working on #1347, @camertron and I realized that it's a little strange to have our test suite in two places. In the interest of having our suite serve as an example for consumers of the framework, we decided to move everything into the sandbox application. * use more specific name for test
53ea6d1
to
f89176c
Compare
In ViewComponent#1347, rendered component has been renamed to rendered content. But its method name seems to be the same as before.
In ViewComponent#1347, rendered component has been renamed to rendered content. But its method name seems to be the same as before.
…1372) * Rename accessor method name: rendered_component => rendered_content In #1347, rendered component has been renamed to rendered content. But its method name seems to be the same as before. * s/rendered_component/rendered_content/ in guide * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md Co-authored-by: Joel Hawksley <joelhawksley@github.com>
* Move tests into sandbox directory In working on ViewComponent#1347, @camertron and I realized that it's a little strange to have our test suite in two places. In the interest of having our suite serve as an example for consumers of the framework, we decided to move everything into the sandbox application. * use more specific name for test
* clean up previews docs * RSpec not rspec * always find preview for action * rename @rendered_component to @rendered_page * Introduce `render_preview` test helper * rename rendered_page to rendered_content * rename benchmark * copy edits * re-add lookbook note * Update docs/CHANGELOG.md Co-authored-by: Blake Williams <blakewilliams@github.com> * Update docs/CHANGELOG.md Co-authored-by: Blake Williams <blakewilliams@github.com> * update depa * add note to changelog * render_preview is opt-in * fix broken reference in benchmark build * always load descendants * add Preview.load_all/load_all! * how about this? * remove duplicate before_action * Ruby 3 changed error formatting! * don't assert with period * mdlint * rename ivar * always load all previews * try this * explicitly load previews * one more try * this one? * load in engine? * uncomment load_previews call * remove call in engine Co-authored-by: Blake Williams <blakewilliams@github.com>
…iewComponent#1372) * Rename accessor method name: rendered_component => rendered_content In ViewComponent#1347, rendered component has been renamed to rendered content. But its method name seems to be the same as before. * s/rendered_component/rendered_content/ in guide * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md Co-authored-by: Joel Hawksley <joelhawksley@github.com>
* Move tests into sandbox directory In working on ViewComponent#1347, @camertron and I realized that it's a little strange to have our test suite in two places. In the interest of having our suite serve as an example for consumers of the framework, we decided to move everything into the sandbox application. * use more specific name for test
* clean up previews docs * RSpec not rspec * always find preview for action * rename @rendered_component to @rendered_page * Introduce `render_preview` test helper * rename rendered_page to rendered_content * rename benchmark * copy edits * re-add lookbook note * Update docs/CHANGELOG.md Co-authored-by: Blake Williams <blakewilliams@github.com> * Update docs/CHANGELOG.md Co-authored-by: Blake Williams <blakewilliams@github.com> * update depa * add note to changelog * render_preview is opt-in * fix broken reference in benchmark build * always load descendants * add Preview.load_all/load_all! * how about this? * remove duplicate before_action * Ruby 3 changed error formatting! * don't assert with period * mdlint * rename ivar * always load all previews * try this * explicitly load previews * one more try * this one? * load in engine? * uncomment load_previews call * remove call in engine Co-authored-by: Blake Williams <blakewilliams@github.com>
…iewComponent#1372) * Rename accessor method name: rendered_component => rendered_content In ViewComponent#1347, rendered component has been renamed to rendered content. But its method name seems to be the same as before. * s/rendered_component/rendered_content/ in guide * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md * Update docs/CHANGELOG.md Co-authored-by: Joel Hawksley <joelhawksley@github.com>
Summary
I've documented this change thoroughly, see the diff ❤️