Add support for RSpec to previews as test cases #1408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
What are you trying to accomplish?
I've noticed that the (Experimental) Previews as test cases don't support RSpec yet, because of how it builds the class name in which it expects the preview:
view_component/lib/view_component/render_preview_helper.rb
Lines 13 to 16 in 1a2e39d
What approach did you choose and why?
This PR adds support for RSpec by checking
self.respond_to?(:described_class)and if so, using"#{self.described_class}Preview"as the preview class name.Anything you want to highlight for special attention from reviewers?
docs/index.mdas I hope #1383 gets merged before this one (or eventually).