render_turbo_stream 0.1.26 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/render_turbo_stream/test_helpers.rb +1 -1
- data/lib/render_turbo_stream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ddfe2fddf5d0990264594bd1bac97f8ad8846d344e63446a1b7d5ac263c0c9d
|
4
|
+
data.tar.gz: 0e56a273cc7cd654e5be6957565c982be9b8ad1fa2a0fa1155f97c5e6815cae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7b25b72283be57909d4085752c0457b2db91de7174df9e8e83f3daf1da784eaca70b509fa1fa5ed28c6cf9f8896916679265914c28db8a0fb00117479d0c858
|
7
|
+
data.tar.gz: 7d8ed294add44a776cd5e5fdfefd51380ef7af5063543fa49cac33155df50a9448966cc1c5599731d665aa0fc9ac1d2bea9fbdfc7a35af44b612c3c18680bed9
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ Working consistently with turbo_stream means shooting lots of partials from the
|
|
6
6
|
|
7
7
|
It sets the status, generates a flash message, handles redirection, pushes it all to the front and comes with predefined helpers for enabling request-specs.
|
8
8
|
|
9
|
+
An overview of how we design a rails-7 application with turbo is [published on dev.to](https://dev.to/chmich/rails-7-vite-wrapping-up-1pia).
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
```ruby
|
@@ -52,7 +54,7 @@ The corresponding partials for flashes could look [like this](https://gitlab.com
|
|
52
54
|
end
|
53
55
|
```
|
54
56
|
|
55
|
-
This will set a status, generate a flash message and perform `stream_partials
|
57
|
+
This will set a status, generate a flash message and perform `stream_partials`, which could result in something like this:
|
56
58
|
|
57
59
|
```ruby
|
58
60
|
stream_partials(
|
@@ -70,7 +72,7 @@ stream_partials(
|
|
70
72
|
)
|
71
73
|
```
|
72
74
|
|
73
|
-
The `stream_partial
|
75
|
+
The `stream_partial` method is nothing else than a singular of `stream_partials`.
|
74
76
|
|
75
77
|
```ruby
|
76
78
|
stream_partial(
|
@@ -100,13 +102,13 @@ RSpec.describe "Articles", type: :request do
|
|
100
102
|
it 'create failed' do
|
101
103
|
post articles_path(params: invalid_params)
|
102
104
|
|
103
|
-
# to which ids turbo-stream
|
105
|
+
# to which html-ids turbo-stream would point
|
104
106
|
expect(partials_ids).to include('flash-box', 'form')
|
105
107
|
|
106
108
|
# which partials where rendered
|
107
109
|
expect(partials_paths).to include('layouts/flash', 'articles/form')
|
108
110
|
|
109
|
-
# partial_response (singular) returns false unless partial responded exactly one time, otherwise the content
|
111
|
+
# partial_response (singular) returns false unless partial responded exactly one time, otherwise the content parsed by nokogiri, see how to handle: https://nokogiri.org/tutorials/searching_a_xml_html_document.html#basic-searching
|
110
112
|
r = partial_response(id: 'flash-box')
|
111
113
|
expect(r.css('div.text-content').first.inner_html).to include('Article could not be created')
|
112
114
|
|
@@ -129,7 +131,7 @@ The test for a redirection might look something like this:
|
|
129
131
|
it 'update success' do
|
130
132
|
a = FactoryBot.create(:article)
|
131
133
|
patch article_path(a, params: valid_params)
|
132
|
-
expect(
|
134
|
+
expect(turbo_redirect_to).to eq(articles_path)
|
133
135
|
end
|
134
136
|
```
|
135
137
|
|