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

add render_preview test helper #1347

Merged
merged 39 commits into from May 31, 2022
Merged

add render_preview test helper #1347

merged 39 commits into from May 31, 2022

Conversation

joelhawksley
Copy link
Contributor

@joelhawksley joelhawksley commented May 4, 2022

Summary

I've documented this change thoroughly, see the diff ❤️

docs/guide/previews.md Show resolved Hide resolved
docs/CHANGELOG.md Outdated Show resolved Hide resolved
docs/CHANGELOG.md Outdated Show resolved Hide resolved
@@ -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 =
Copy link
Member

@BlakeWilliams BlakeWilliams May 10, 2022

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.

Copy link
Contributor Author

@joelhawksley joelhawksley May 11, 2022

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.

Copy link
Contributor

@cpjmcquillan cpjmcquillan Jun 1, 2022

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)

Copy link
Collaborator

@rmacklin rmacklin Jun 2, 2022

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
Copy link
Member

@BlakeWilliams BlakeWilliams May 10, 2022

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?

Copy link
Contributor Author

@joelhawksley joelhawksley May 11, 2022

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!

Copy link
Member

@BlakeWilliams BlakeWilliams left a comment

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.

joelhawksley added a commit that referenced this issue May 26, 2022
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.
joelhawksley added a commit that referenced this issue May 26, 2022
* 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
@joelhawksley joelhawksley merged commit 4bceecf into main May 31, 2022
79 of 81 checks passed
@joelhawksley joelhawksley deleted the render_preview branch May 31, 2022
yhirano55 added a commit to yhirano55/view_component that referenced this issue Jun 1, 2022
In github#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.
yhirano55 added a commit to yhirano55/view_component that referenced this issue Jun 1, 2022
In github#1347, rendered component has been renamed to rendered content.

But its method name seems to be the same as before.
joelhawksley added a commit that referenced this issue Jun 1, 2022
…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>
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.

None yet

6 participants