Skip to content

Commit 1278b8b

Browse files
rylanbjoelhawksley
andauthored
Documentation Update: Add a section for how to add the render_inline helpers to RSpec tests (#2162)
* Add a section for hwo to add the render_inline helpers to View Component tests Source: https://stackoverflow.com/questions/70041733/integrating-viewcomponent-with-rspec * Apply suggestions from code review * Adding a note on the documentation update for RSpec. Fixing lint callout for double quoted strings instead of single * Update docs/CHANGELOG.md --------- Co-authored-by: Joel Hawksley <[email protected]>
1 parent 8b441cc commit 1278b8b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nav_order: 5
1010

1111
## main
1212

13+
* Updates testing docs to include an example of how to use with RSpec.
14+
15+
*Rylan Bowers*
16+
1317
* Add `--skip-suffix` option to component generator.
1418

1519
*KAWAKAMI Moeki*

docs/guide/testing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ _Note: `assert_selector` only matches on visible elements by default. To match o
3030

3131
For debugging purposes, the `rendered_content` test helper outputs the rendered HTML.
3232

33+
## Use with RSpec
34+
35+
To enable ViewComponent test helpers in RSpec, add:
36+
37+
```ruby
38+
# spec/rails_helper.rb
39+
require "view_component/test_helpers"
40+
41+
RSpec.configure do |config|
42+
# ...
43+
44+
config.include ViewComponent::TestHelpers, type: :component
45+
end
46+
```
47+
3348
## Testing Slots
3449

3550
```ruby

0 commit comments

Comments
 (0)