Skip to content

Commit

Permalink
Documentation Update: Add a section for how to add the render_inline …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
rylanb and joelhawksley authored Dec 18, 2024
1 parent 8b441cc commit 1278b8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 5

## main

* Updates testing docs to include an example of how to use with RSpec.

*Rylan Bowers*

* Add `--skip-suffix` option to component generator.

*KAWAKAMI Moeki*
Expand Down
15 changes: 15 additions & 0 deletions docs/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ _Note: `assert_selector` only matches on visible elements by default. To match o

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

## Use with RSpec

To enable ViewComponent test helpers in RSpec, add:

```ruby
# spec/rails_helper.rb
require "view_component/test_helpers"

RSpec.configure do |config|
# ...

config.include ViewComponent::TestHelpers, type: :component
end
```

## Testing Slots

```ruby
Expand Down

0 comments on commit 1278b8b

Please sign in to comment.