Skip to content

Commit

Permalink
Rename accessor method name: rendered_component => rendered_content (V…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
2 people authored and claudiob committed Jan 3, 2024
1 parent a2338e0 commit f7afcd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ title: Changelog

## main

* Rename private accessor `rendered_component` to `rendered_content`.

*Yoshiyuki Hirano*, *Simon Dawson*

## 2.56.0

* Introduce experimental `render_preview` test helper. Note: `@rendered_component` in `TestHelpers` has been renamed to `@rendered_content`.
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ def test_render_component
end
```

Alternatively, assert against the raw output of the component, which is exposed as `rendered_component`:
Alternatively, assert against the raw output of the component, which is exposed as `rendered_content`:

```ruby
def test_render_component
render_inline(ExampleComponent.new(title: "my title")) { "Hello, World!" }

assert_includes rendered_component, "Hello, World!"
assert_includes rendered_content, "Hello, World!"
end
```

Expand Down Expand Up @@ -202,9 +202,9 @@ RSpec.describe ExampleComponent, type: :component do
it "renders component" do
render_inline(described_class.new(title: "my title")) { "Hello, World!" }

expect(rendered_component).to have_css "span[title='my title']", text: "Hello, World!"
expect(rendered_content).to have_css "span[title='my title']", text: "Hello, World!"
# or, to just assert against the text
expect(rendered_component).to have_text "Hello, World!"
expect(rendered_content).to have_text "Hello, World!"
end
end
```
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def refute_component_rendered
end

# @private
attr_reader :rendered_component
attr_reader :rendered_content

# Render a component inline. Internally sets `page` to be a `Capybara::Node::Simple`,
# allowing for Capybara assertions to be used:
Expand Down

0 comments on commit f7afcd1

Please sign in to comment.