README.md in actionview-component-1.6.0 vs README.md in actionview-component-1.6.1
- old
+ new
@@ -30,11 +30,11 @@
```
In `config/application.rb`, add:
```bash
-require "action_view/component"
+require "action_view/component/railtie"
```
## Guide
### What are components?
@@ -172,11 +172,11 @@
Example for a `Post` model:
`render(@post)`
```ruby
-class PostComponent < ActionView::Component
+class PostComponent < ActionView::Component::Base
def initialize(post)
@post = post
end
end
```
@@ -202,16 +202,14 @@
### Testing
Components are unit tested directly. The `render_inline` test helper wraps the result in `Nokogiri.HTML`, allowing us to test the component above as:
```ruby
-require "action_view/component/test_helpers"
+require "action_view/component/test_case"
-class MyComponentTest < Minitest::Test
- include ActionView::Component::TestHelpers
-
- def test_render_component
+class MyComponentTest < ActionView::Component::TestCase
+ test "render component" do
assert_equal(
%(<span title="my title">Hello, World!</span>),
render_inline(TestComponent, title: "my title") { "Hello, World!" }.to_html
)
end
@@ -223,10 +221,10 @@
#### Action Pack Variants
To test a specific variant you can wrap your test with the `with_variant` helper method as:
```ruby
-def test_render_component_for_tablet
+test "render component for tablet" do
with_variant :tablet do
assert_equal(
%(<span title="my title">Hello, tablets!</span>),
render_inline(TestComponent, title: "my title") { "Hello, tablets!" }.css("span").to_html
)